Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
鉴于此数据框:
b a d c 3 -2 1 3 2 4 1 1 3 2 5 1 1 3 2
是否可以像这样重命名行索引?
b a d c xxx -2 1 3 2 yyy 1 1 3 2 zzz 1 1 3 2
本质上,我没有数字索引,而是将字符串作为 id,就像哈希表一样。
test<-data.frame(b=c(-2,1,1),a=c(1,1,1),d=c(3,3,3),c=c(2,2,2),row.names=c(3,4,5)) row.names(test)<-c('xxx','yyy','zzz') > test b a d c xxx -2 1 3 2 yyy 1 1 3 2 zzz 1 1 3 2
是的,像这样。
row.names(someDataFrame) = someVectorOfNames