我需要阅读以下数据文件夹中的wdbc.data: archive.ics.uci.edu/ml/machine-learning-databases/breast-cancer-wisconsin/
I need to read the ''wdbc.data' in the following data folder: archive.ics.uci.edu/ml/machine-learning-databases/breast-cancer-wisconsin/
在R中执行此操作很容易使用命令read.csv,但由于标题缺少如何添加它?我有信息但不知道如何做到这一点,我宁愿不编辑数据文件。
Doing this in R is easy using command read.csv but as the header is missing how can I add it? I have the information but don't know how to do this and I'd prefer do not edit the data file.
推荐答案您可以执行以下操作:
加载数据:
test <- read.csv( "archive.ics.uci.edu/ml/machine-learning-databases/breast-cancer-wisconsin/breast-cancer-wisconsin.data", header=FALSE)请注意,头的默认值参数 read.csv 是 TRUE 所以为了获得你需要设置的所有行到 FALSE 。
Note that the default value of the header argument for read.csv is TRUE so in order to get all lines you need to set it to FALSE.
将数据添加到data.frame中的不同列中
Add names to the different columns in the data.frame
names(test) <- c("A","B","C","D","E","F","G","H","I","J","K")并且我知道的更快(不是重新加载整个数据集):
or alternative and faster as I understand (not reloading the entire dataset):
colnames(test) <- c("A","B","C","D","E","F","G","H","I","J","K")更多推荐
如何在R中的数据集中添加标题?
发布评论