使用 read.table 讀取多變量資料
從檔案或外部 URL 讀取多變量資料,通常可依資料來源型別使用 read.table() 或 read.csv() 指令。在本練習中,你要從 UCI 機器學習網站讀取 wine 資料集。資料集的完整說明可在這裡找到。
想了解更多在 R 中讀取資料的方法,你可以參考 DataCamp 的課程:Introduction to Importing Data in R 與 Intermediate Importing Data in R。完成本練習後,wine 資料集會為你預先載入。
本練習屬於課程
R 的多變量機率分配
練習說明
- 使用
read.table()函式從 https://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data 讀取wine資料集。 - 顯示資料集前 4 筆資料。
- 找出資料集的維度。
- 檢查資料集的欄位名稱。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Read in the wine dataset
wine <- read.table("___", sep = ",")
# Print the first four entries
head(___)
# Find the dimensions of the data
dim(___)
# Check the names of the wine dataset
___