[R] Syntax for order()

Kevin E. Thorpe kevin.thorpe at utoronto.ca
Tue Mar 25 19:42:47 CET 2014


On 03/25/2014 02:36 PM, John Kane 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)
> dat1[order(val), ]  # Gives Error in order(val) : object 'val' not found
>
> dat1[order(dat1[,2]), ] # Works just fine.
>
> John Kane
> Kingston ON Canada

I don't think the behaviour has changed. I bet dat1[order(dat1$val), ] 
works just fine.

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.thorpe at utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016




More information about the R-help mailing list