I'm not sure what's incorrect about your result, but the following works: d=data.frame(a=sample(letters[1:5],10,rep=T),b=rnorm(10),c=sample(1:10,10)); d d[order(d$a,d$c),]
or, you can use orderBy: lib(doBy) orderBy(~a+b,data=d) #use a - sign to sort in descending sequence Did you leave off the tilde in your orderBy example? hth David Freedman, CDC Atlanta -- View this message in context: http://n4.nabble.com/ordering-columns-in-a-data-frame-tp1587294p1587318.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.