我有一个2x5数据框,其行名和列名如下所示:
test <- matrix(NA,nrow=2,ncol=5)
test[1,] = c(2,3,6,8,9)
test[2,] = c(5,3,2,7,8)
colnames(test) = c('aa','bb','cc','dd','ee')
rownames(test) = c('first','second')
test = data.frame(test)
我想将数据框的列映射到此向量指定的格式:
test2 = c('ee','cc','dd','bb','aa')
有谁知道我该怎么做?