1

このデータフレームを考えると:

       b  a  d c
    3 -2  1  3 2
    4  1  1  3 2
    5  1  1  3 2

Is it possible to rename the row indices like so?

         b  a  d c
    xxx -2  1  3 2
    yyy  1  1  3 2
    zzz  1  1  3 2

Essentially, instead of having numeric indices, I have strings as id's, like a hash table.

4

2 に答える 2

3
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
于 2012-07-26T00:02:54.167 に答える
1

はい、このように。

row.names(someDataFrame) = someVectorOfNames

于 2012-07-26T00:03:12.603 に答える