[R] how to order a dataframe ?

Spencer Graves spencer.graves at pdf.com
Wed May 7 18:47:55 CEST 2003


I've used 'order' successfully.  Consider the following:

df1 <- data.frame(x=rnorm(9))
df1
df1[order(df1$x),, drop=F]

If you provide an example of what did not work, someone might be able to 
help more.

spencer graves

Laurent Faisnel wrote:
> Hi,
> I've got a problem which seemed simple to me at first view, but which I 
> haven't managed to solve yet. I have a dataframe, or a matrix, and I 
> would like to order it along with one of the variables/columns. I tried 
> to use order() but it remained quite unclear to me. How should I proceed ?
> Thanks in advance (I guess that's not very difficult a question for most 
> of you)
> 
> Laurent
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list