Sort a data frame with respect to more than one variable
Le 21.09.2005 10:54, Marc Bernard a ??crit :
Dear All, How can I sort a data frame with respect to more than one variable? I know that for one variable X one may use: df[order(df$X), ] where df is the data frame containing X. Many thanks, Bernard
You already know the answer of that question. order() accepts more than one variable. x <- rep(rbinom(5,size=4,prob=.5), 6) y <- rnorm(30) cbind(x,y)[ order(x,y) , ] Romain
visit the R Graph Gallery : http://addictedtor.free.fr/graphiques ~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ ~~~~~~ Romain FRANCOIS - http://addictedtor.free.fr ~~~~~~ ~~~~ Etudiant ISUP - CS3 - Industrie et Services ~~~~ ~~ http://www.isup.cicrp.jussieu.fr/ ~~ ~~~~ Stagiaire INRIA Futurs - Equipe SELECT ~~~~ ~~~~~~ http://www.inria.fr/recherche/equipes/select.fr.html ~~~~~~ ~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~