[R] Ordering a matrix by another variable

Daniel Pick Daniel.Pick at biogenidec.com
Mon Jan 2 23:26:10 CET 2006


Hello,
    Given the matrix M
    1 5     4
    2       4     6
    3       8             5
    4         2              7

and the vector V 4,2,1,3,   I would like to order the rows in M according
to the indices in V, that is, I want output

    4 2     7
    2 4     6
    1 5     4
    3 8     5

How do I do this?  This is not a standard ascending or descending sort.

Dan




More information about the R-help mailing list