使用txt文件命名r中的多个列

时间:2015-11-19 16:16:43

标签: r

我想使用txt文件在r中的data.frame中命名列。我操纵原始的txt文件来提取文本,并从预期的列名称中创建一个列表。但问题是我最终看到列名中显示的列表残余是不可取的。我会很感激建议做什么而不是创建列表?如何获取文本并使用它来命名r中的列?

数据框的列名在我的代码末尾如下所示:

#read in the txt file
features<-read.table("C:/Adatok/coursera/3_getting and cleaning     data/Quizes/Assignment/UCI HAR Dataset/features.txt", stringsAsFactors = FALSE)

> features[1:3,1:2]
  V1                V2
1  1 tBodyAcc-mean()-X
2  2 tBodyAcc-mean()-Y
3  3 tBodyAcc-mean()-Z

#removed the first column with this command
features$V1<-NULL

#made a list
features.list<-split(features, seq(nrow(features)))

#named columns
colnames(mergedData)[3:563]<- features.list

这就是我所做的:

source

0 个答案:

没有答案