Hi Glen, -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jones, Glen R
If a matrix with 5 columns has been defined and the first two columns need to be sorted in ascending order, how can this be achieved whilst ensuring the other 3 columns data are in relative position to the sorted columns? does the following example-code help you? mymatrix should resemble the structure of your (original) matrix. mymatrix2 is the new, sorted matrix. mymatrix <- matrix(runif(80), ncol=5) mymatrix[,1] <- sample(c(1,2), size=length(mymatrix[,1]), replace=TRUE) mymatrix mymatrix2 <- mymatrix[order(mymatrix[,1],mymatrix[,2]),] mymatrix2 Best, Roland +++++ This mail has been sent through the MPI for Demographic Rese...{{dropped}} ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html