read_delim
就像 read.table() 是 utils 的主要函式,read_delim() 是 readr 的主要函式。
read_delim() 需要兩個必填引數:
file:包含資料的檔案delim:在資料檔中用來分隔數值的字元
你會再次使用 potatoes.txt(檢視);這個檔案使用定位字元("\t")作為分隔符,且第一行並沒有包含欄名。它已經在你的工作目錄中,所以可以直接開始。和之前一樣,向量 properties 可用來設定 col_names。
本練習屬於課程
R 資料匯入入門
練習說明
- 使用
read_delim()匯入"potatoes.txt"中的所有資料,並將結果資料框存成potatoes。 - 印出
potatoes。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Column names
properties <- c("area", "temp", "size", "storage", "method",
"texture", "flavor", "moistness")
# Import potatoes.txt using read_delim(): potatoes
potatoes <- ___
# Print out potatoes
___