This question should be directed to R-Help Anyway, sorted <- apply(unsorted,2,sort) should do it.
Ken On 14/10/2010, at 7:06 PM, Desmond Lim wrote: > Hi, > > I have this matrix > > unsorted$A with 5 columns (all numeric). > > Currently I'm sorting the columns like this: > > sorted$A[,1] <- sort(unsorted$A[,1]) > sorted$A[,2] <- sort(unsorted$A[,2]) ... > > I have tried doing > > sorted$A <- unsorted$A[do.call(order, data.frame(unsorted$A)),] but it > sorts the first column then the 2nd column which it ties to the 1st > column, then the 3rd which is tied to the 2nd, etc. I need all the > columns to be independently sorted. > > Any help is appreciated. > > Desmond > > _______________________________________________ > R-SIG-Mac mailing list > R-SIG-Mac@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/r-sig-mac > _______________________________________________ R-SIG-Mac mailing list R-SIG-Mac@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-mac