Re: [R] function order

2011-04-06 Thread Dennis Murphy
Hi: Try this: abc<-cbind(c(1,6,2),c(2,5,3),c(3,2,1)) abc[order(abc[, 1], decreasing = TRUE), ] [,1] [,2] [,3] [1,]652 [2,]231 [3,]123 HTH, Dennis On Wed, Apr 6, 2011 at 3:35 AM, Yan Jiao wrote: > Dear All > > I'm trying to sort a matrix using function

Re: [R] function order

2011-04-06 Thread Philipp Pagel
On Wed, Apr 06, 2011 at 11:35:32AM +0100, Yan Jiao wrote: > abc<-cbind(c(1,6,2),c(2,5,3),c(3,2,1))## matrix I want to sort > > if I do > abc[ order(abc[,3]), increasing = TRUE] Jim already pointed out that the argument needs to go inside the parenthes of the order function. In addition, order has

Re: [R] function order

2011-04-06 Thread Jim Lemon
On 04/06/2011 08:35 PM, Yan Jiao wrote: Dear All I'm trying to sort a matrix using function order, Some thing really odd: e.g. abc<-cbind(c(1,6,2),c(2,5,3),c(3,2,1))## matrix I want to sort if I do abc[ order(abc[,3]), increasing = TRUE] the result is correct [,1] [,2] [,3] [1,]2

[R] function order

2011-04-06 Thread Yan Jiao
Dear All I'm trying to sort a matrix using function order, Some thing really odd: e.g. abc<-cbind(c(1,6,2),c(2,5,3),c(3,2,1))## matrix I want to sort if I do abc[ order(abc[,3]), increasing = TRUE] the result is correct [,1] [,2] [,3] [1,]231 [2,]652 [3,]12