-----Original Message-----
From: r-help-bounces at r-project.org
[mailto:r-help-bounces at r-project.org] On Behalf Of Lisa
Sent: Tuesday, May 24, 2011 12:00 PM
To: r-help at r-project.org
Subject: [R] Order a matrix
Dear all,
I just want to order a matrix using several columns in a matrix. For
example:
x <- matrix(sample(c(1:5), 60, replace = T), 10, 6).
If I order the matrix by the first two columns, I will do it
like this:
x[order(x[, 1], x[, 2]), ].
But when I repeat this work many times and the columns will
change each time
in a simulation study, how can I assign the arguments of order()? For
example, in the first iteration, the columns needing to order
is the first
two columns, in the second iteration, the columns needing to
order is the
first, second, and fourth column? ....
I would appreciate any help on this question. Thanks a lot.
Lisa
--
View this message in context:
http://r.789695.n4.nabble.com/Order-a-matrix-tp3547923p3547923.html
Sent from the R help mailing list archive at Nabble.com.