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
___