[R] sorting matrix elements by given rownames and colnames

Albert Vilella avilella at gmail.com
Tue Jun 13 13:45:06 CEST 2006


Hi all,

I would like to know if it is possible to sort the columns and rows in
a matrix given a specified order of their colnames and rownames. For
example:

I would like the original matrix:
  
     RNO  FRU   ANG  CEL  DAR  PTR
RNO 3.45 1.35  2.16 2.25 1.43 1.20
FRU 1.31  Inf  2.22 2.36 1.34 1.40
ANG 1.30 1.30 11.61 1.37 1.33 1.35
CEL 1.34 1.35  1.37  Inf 1.37 1.40
DAR 1.40 1.29  2.29 2.39 9.62 1.48
PTR 1.08 1.30  2.06 2.17 1.39 8.17

To be sorted in a top/down and left/right way in this order
instead: "FRU","ANG","CEL","PTR","RNO","DAR".

Thanks in advance,

    Albert.



More information about the R-help mailing list