[R] Independant column sorting using sort.list

Douglas Bates bates at stat.wisc.edu
Wed Dec 11 00:55:03 CET 2002


Jeremy Z Butler <jeremybutler at paradise.net.nz> writes:

> Hi,
> I'm trying to _independantly_ sort the columns of a data frame. 
> 
> Using:
> > varespec[sort.list(varespec[,1]),]
> the columns are sorted *by the first row*.
>  
> How would I modify this so that all columns are sorted independantly (the result
> being *all* columns are rearranged from smallest to biggest not just the first)?

Apply the sort rather than using sort.list.

varespec <- data.frame(lapply(varespec, sort))




More information about the R-help mailing list