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)? Cheers, Jeremy
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))