Re: [R] Sorting a matrix by a column

2008-08-04 Thread Dimitris Rizopoulos
probably you need order(), e.g., data[order(data[, 2]), ] I hope it helps. Best, Dimitris John Sorkin wrote: R 2.6 Windows XP I have a 100x4 matirx data<-matrix(nrow=100,ncol=4) I would like to sort the entire matrix by column two, i.e. data[,2] I looked at the help page for sort() but c

Re: [R] Sorting a matrix by a column

2008-08-04 Thread Prof Brian Ripley
On Mon, 4 Aug 2008, John Sorkin wrote: R 2.6 Windows XP I have a 100x4 matirx data<-matrix(nrow=100,ncol=4) I would like to sort the entire matrix by column two, i.e. data[,2] I looked at the help page for sort() but can not determine how I can use it to sort a matrix on one of the matrix's

[R] Sorting a matrix by a column

2008-08-04 Thread John Sorkin
R 2.6 Windows XP I have a 100x4 matirx data<-matrix(nrow=100,ncol=4) I would like to sort the entire matrix by column two, i.e. data[,2] I looked at the help page for sort() but can not determine how I can use it to sort a matrix on one of the matrix's columns. Thanks, John John David Sorkin