如何使用列中的否定条目按降序对数据框进行排序

时间:2015-01-19 16:42:53

标签: r sorting

我有一个数据框:

          Name                               Cummu.Score      Call 
ADAM metallopeptidase domain 32                    -2           A
cartilage intermediate layer protein 2             -2           A
chemokine (C-C motif) ligand 5                      6           P
cytochrome P450, family 2, subfamily E             -2           A
discoidin domain receptor tyrosine kinase 1         2           P
EPH receptor B3                                     2           P
guanylate cyclase activator 1A (retina)            -2           A
heat shock 70kDa protein 6 (HSP70B')                2           P
matrix metallopeptidase 14 (membrane-inserted)      2           P
mitogen-activated protein kinase 1                  4           P
paired box 8                                        4           P
paired box 8                                        2           P
phosphatidylinositol glycan anchor biosynthesis,    2           P
proline rich 22                                    -4           A
protein tyrosine phosphatase, non-receptor type 21 -2           A
replication factor C (activator 1) 2, 40kDa         4           P
spermatogenesis associated 17                      -2           A
thyroid hormone receptor, alpha                     0           0 
transmembrane protein 196                          -2           A
ubiquitin-like modifier activating enzyme 7         4           P
ubiquitin-like modifier activating enzyme 7         2           P
WAP four-disulfide core domain 2                    0           0

使用d2=d2[ order(d2[,2],decreasing=TRUE),]对数据框d2进行排序后,我的数据框如下所示:

Gene Name                                  Cummu.Score  Call
chemokine (C-C motif) ligand 5                    6          P
mitogen-activated protein kinase 1                4          P
paired box 8                                      4          P
replication factor C (activator 1) 2, 40kDa       4          P
ubiquitin-like modifier activating enzyme 7       4          P
discoidin domain receptor tyrosine kinase 1       2          P
EPH receptor B3                                   2          P
heat shock 70kDa protein 6 (HSP70B')              2          P
matrix metallopeptidase 14 (membrane-inserted)    2          P
paired box 8                                      2          P
phosphatidylinositol glycan anchor                2          P
ubiquitin-like modifier activating enzyme 7       2          P
thyroid hormone receptor, alpha                   0          0
WAP four-disulfide core domain 2                  0          0
proline rich 22                                  -4          A
ADAM metallopeptidase domain 32                  -2          A
cartilage intermediate layer protein 2           -2          A
cytochrome P450, family 2, subfamily E 1         -2          A
guanylate cyclase activator 1A (retina)          -2          A
protein tyrosine phosphatase, non-receptor type  -2          A
spermatogenesis associated 17                    -2          A
transmembrane protein 196                        -2          A

但是这里有一些问题。正如您在排序数据框中可以看到的那样,首先给出-4,然后给出-2。对于负值,它没有排序。如何解决这个问题。提前谢谢。

0 个答案:

没有答案