[R] sort.list, order
    Jason Turner 
    jasont at indigoindustrial.co.nz
       
    Thu Nov 14 13:38:34 CET 2002
    
    
  
On Fri, Nov 15, 2002 at 07:46:07AM +0900, Jun Takeda wrote:
> I think "sort.list" and "order" somtimes return incorrect results. 
> 
> ===R1.6.1===
> > sort.list(c(2,3,1,5,4))
> [1] 3 1 2 5 4
> > order(c(2,3,1,5,4))
> [1] 3 1 2 5 4
> >
> ===========
order and sort.list return indices, not values, so 
those are correct.  Try:
zz <- c(2,3,1,5,4)
zz[order(zz)]
Cheers
Jason
-- 
Indigo Industrial Controls Ltd.
64-21-343-545
jasont at indigoindustrial.co.nz
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
    
    
More information about the R-help
mailing list