RE: [R] R matrix sorting question

2005-05-19 Thread Tuszynski, Jaroslaw W.
Try: > A=matrix(c(1,3,4,5,7, -0.2, 0.8, 0.3, 0.2, 0.9 ),5,2) > A [,1] [,2] [1,]1 -0.2 [2,]3 0.8 [3,]4 0.3 [4,]5 0.2 [5,]7 0.9 > A[order(A[,2]), ] [,1] [,2] [1,]1 -0.2 [2,]5 0.2 [3,]4 0.3 [4,]3 0.8 [5,]7 0.9 Jarek

RE: [R] R matrix sorting question

2005-05-19 Thread Huntsinger, Reid
You can use "order" as follows: > p <- order(aaa[,2]) > aa[p,] p is the permutation putting aaa[,2] in ascending order, then aaa[p,] reorders the rows according to p. Reid Huntsinger -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent