[R] sort.list, order
Robert Cunningham
robut at forest.go.th
Fri Nov 15 02:12:02 CET 2002
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list