Displaying 1 result from an estimated 1 matches for "listofarg".
Did you mean:
listofargs
2011 Sep 23
1
sorting multiple columns of a matrix
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, in
any way I would like to sort for all columns from 1:ncol(x). How to achieve
this?
Best