可能重复:
如何在 R 中按列对数据框进行排序
大家:我想使用R对组内的数据进行排序。例如:数据是:
geneID Nr.annotation
CL1002 uncharacterized
CL1002 uncharacterized
CL1002 uncharacterized
CL1002 uncharacterized
CL1002 uncharacterized
CL1002 uncharacterized
CL1019 PREDICTED:
CL1019 PREDICTED:
CL1019 predicted
CL1019 PREDICTED:
CL1019 PREDICTED:
CL1019 predicted
CL1019 predicted
CL1019 hypothetical
CL10246 unnamed
CL10246 predicted
CL10246 unnamed
CL10246 unnamed
CL10246 unnamed
CL10246 unnamed
CL10246 unnamed
CL1064 octicosapeptide/Phox/Bem1p
CL1064 octicosapeptide/Phox/Bem1p
CL1064 serine/threonine
CL1064 serine/threonine
CL1064 serine/threonine
CL1064 serine/threonine
这是原始数据。请复制并使用如下代码:
read.table("clipboard",strip.white=T,header=T)
然后,我该怎么办?排序后,我希望结果是这样的:
geneID Nr.annotation
CL1002 PREDICTED:
CL1002 uncharacterized 4
CL1019 PREDICTED: 6
CL1019 hypothetical 1
CL1019 uncharacterized 1
CL10246 predicted 1
CL10246 unnamed 6
CL1064 octicosapeptide/Phox/Bem1p 2
CL1064 serine/threonine 4