使用 read.table 读取多变量数据
从文件或外部 URL 读取多变量数据通常可以使用 read.table() 或 read.csv(),具体取决于数据源的类型。本练习中,您将从 UCI 机器学习网站读取 wine 数据集。关于该数据集的完整说明见此处:here。
有关在 R 中读取数据的更多细节,您可以参考课程 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
___