目前,我有一个 csv 文件,如下所示
ID grade-1 grade-2 grade-3
1 0.004461027 0.002740424 0.002955164
2 0.055690775 0.045791653 0.17440305
3 0.048901623 0.042439538 0.027306325
4 0.20013265 0.0637944 0.081362503
我读表为
test.matrix<-data.frame(read.table("test.csv",sep=",",header=T))
我想生成一个新表,其中每一行都已排序
ID highest grade the second grade the third grade
1 grade-1:0.004461027 grade-3:0.002955164 grade-2:0.002740424
2 grade-3:0.17440305 grade-1:0.055690775 grade-2:0.045791653
3 grade-1:0.048901623 grade-2:0.042439538 grade-3:0.027306325
4 grade-1:0.20013265 grade-3:0.081362503 grade-2:0.0637944
如何对每一行进行排序?并且为了生成输出,如何将字符(例如,grade-1
数字值)0.004461027
放入单个条目中,例如grade-1:0.004461027
?