在R中命名列

时间:2017-06-11 19:14:50

标签: r csv

我希望有人可以帮我解决这个问题:

read.csv(file="file:///C:/Users/Erin/Downloads/clausen.csv", header=TRUE, sep=",")
read.csv(file="file:///C:/Users/Erin/Downloads/Mather.csv", header=TRUE, sep=",")
c(rep(1,8),rep(2,17),rep(3,12),rep(4,18),rep(5,26),rep(6,31))
c(rep(1,8),rep(2,17),rep(2,12),rep(2,18),rep(3,26),rep(3,31))
cbind(c(rep(1,8),rep(2,17),rep(3,12),rep(4,18),rep(5,26),rep(6,31)),c(rep(1,8),rep(2,17),rep(2,12),rep(2,18),rep(3,26),rep(3,31)))
cbind(Mather,c(rep(1,8),rep(2,17),rep(3,12),rep(4,18),rep(5,26),rep(6,31)),c(rep(1,8),rep(2,17),rep(2,12),rep(2,18),rep(3,26),rep(3,31)))

我需要命名Ecotype(第一行数据)和Subspecies(第二行)列。

1 个答案:

答案 0 :(得分:2)

您可能希望在从read.csv读入后存储数据,然后更改列名称,如下所示。

df <- read.csv(file="file:///C:/Users/Erin/Downloads/clausen.csv", header=TRUE, sep=",") 
colnames(df) <- c("Ecotype","Subspecies")
相关问题