假设我有:
Assembly<-t(read.table("E:\\test\\exp1.csv",sep="|",header=FALSE)[1:4416,5])
使用以下方式分配行名:
rownames(data)[1]<-"Assembly"
其中data是一个数据帧,包含许多与上述类似的行。我可以使用一个命令吗?
答案 0 :(得分:0)
read.table(text = "1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18",
col.names = c("A", "B", "C", "D", "Assembly", "F"))
# A B C D Assembly F
# 1 1 2 3 4 5 6
# 2 7 8 9 10 11 12
# 3 13 14 15 16 17 18
t(read.table(text = "1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18",
col.names = c("A", "B", "C", "D", "Assembly", "F"))[1:2, "Assembly", drop = FALSE])
# 1 2
# Assembly 5 11