[R] Sorting a Data Frame

S Ellison S.Ellison at LGCGroup.com
Tue Jan 26 14:19:31 CET 2016


> On 23.01.2016 01:21, Robert Sherry wrote:
> > In R, I run the following commands:
> >      df = data.frame( x=runif(10), y=runif(10) )
> >      df2 = df[order(x),]
> 
> 
> You use another x from your workspace, you actually want to
> 
> 
>   df2 = df[order(df[,"x"]),]

or 
df[order(df$x),] 

And just to prevent yet more confusion, you might also want to avoid 'df' as a name. 'df' is the function that returns the density of the F distribution ...

S Ellison



*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}



More information about the R-help mailing list