[R] Syntax for order()

John Kane jrkrideau at inbox.com
Tue Mar 25 20:28:56 CET 2014


  Okay I  feel spoilt all over  again.  :)

John Kane
Kingston ON Canada


> -----Original Message-----
> From: h.wickham at gmail.com
> Sent: Tue, 25 Mar 2014 14:24:00 -0500
> To: jrkrideau at inbox.com
> Subject: Re: [R] Syntax for order()
> 
> If you want to continue to be spoiled, try:
> 
> library(dplyr)
> arrange(dat1, val)
> 
> Hadley
> 
> On Tue, Mar 25, 2014 at 2:20 PM, John Kane <jrkrideau at inbox.com> wrote:
>> Thank.
>> 
>> Once I got Sarah's email I realised I should have been usling with().
>> Hadley's ggplot syntax has spoiled/confused me.
>> 
>> John Kane
>> Kingston ON Canada
>> 
>> 
>>> -----Original Message-----
>>> From: seeliger.curt at epa.gov
>>> Sent: Tue, 25 Mar 2014 19:02:22 +0000
>>> To: r-help at r-project.org, jrkrideau at inbox.com
>>> Subject: RE: [R] Syntax for order()
>>> 
>>>>> dat1[order(val), ]  # Gives Error in order(val) : object 'val' not
>>>>> found
>>>>> 
>>>>> dat1[order(dat1[,2]), ] # Works just fine.
>>>> 
>>>> dat1[order(dat1$val), ]
>>>> 
>>>> unless you used attach(dat1).
>>> 
>>> Better to avoid 'attach' altogether and go with the first suggestion.
>>> That can get rather unwieldy when ordering on many columns, in which
>>> case
>>> with() is handy:
>>> 
>>> dat1[with(dat1, order(val)),]
>>> 
>>> 
>>> --
>>> Curt Seeliger, Data Ranger
>>> Raytheon Information Services, Contractor to ORD
>>> seeliger.curt at epa.gov
>>> 541-754-4638
>>> 
>>> 
>>> 
>>> Sarah
>>> 
>>> On Tue, Mar 25, 2014 at 2:36 PM, John Kane <jrkrideau at inbox.com> wrote:
>>>> Has there been a change in the syntax for order() or am I just making
>>>> some stupid mistake here?
>>>> 
>>>> dat1 <-read.table(text="
>>>> name val
>>>> Alex 4
>>>> Jim 10
>>>> Fred 8
>>>> Julie 44
>>>> ",sep="",header=TRUE,stringsAsFactors=FALSE)
>>>> 
>>>> John Kane
>>>> Kingston ON Canada
>>>> 
>>> 
>>> --
>>> Sarah Goslee
>>> http://www.functionaldiversity.org
>>> 
>>> ______________________________________________
>>> R-help at 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.
>> 
>> ____________________________________________________________
>> FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
>> 
>> ______________________________________________
>> R-help at 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.
> 
> 
> 
> --
> http://had.co.nz/

____________________________________________________________
FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!




More information about the R-help mailing list