Re: [R] sorting multiple columns of a matrix

2011-09-23 Thread William Dunlap
-- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Maxim > Sent: Friday, September 23, 2011 9:22 AM > To: r-help > Subject: [R] sorting multiple columns of a matrix > > Hi, > > > I have a question about how to sort a matrix for

[R] sorting multiple columns of a matrix

2011-09-23 Thread Maxim
Hi, I have a question about how to sort a matrix for multiple columns. dat<-sample(0:1,1000,replace=T) matrix(dat,ncol=5,nrow=200)->x I want to order like the following: x[order(x[,1],x[,2],x[,3],x[,4],x[,5]),]->x My problem: the number of columns of the matrix to be sorted is variable,