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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Dear all: 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>========== These results must be "[1] 2 3 1 5 4". Sincerely, Jun Takeda -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Dear Jun, It is working fine. It is just that it is returning the vector indices in the correct order-you think it is returning the values. try this c(2,3,1,5,4)[order(c(2,3,1,5,4))] or x<-c(2,3,1,5,4) #easier to follow x[order(x)] and look at ?sort Cheers, Robert Cunningham Jun Takeda writes: > > Dear all: > > 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 > > > ========== > > These results must be "[1] 2 3 1 5 4". > > Sincerely, > > Jun Takeda > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._