[R] How to sort the elements in a matrix?

FMH kagba2006 at yahoo.com
Tue Sep 22 19:20:27 CEST 2009


Dear All,

Let ab is the combination of matrices a and b.


a <- matrix(c(1,2,3,4), nrow = 2, ncol = 2)
b <- matrix(c(4,3,1,2), nrow = 2, ncol = 2)
ab <- rbind(a, b)
 
From matrix ab, could someone give some advice on the way to sort all elements in column 2, by the sequence of the elements in column 1 in ascending order?
 
Thank you.
Fir







More information about the R-help mailing list