[R] sorting ascending descending?

Ramon Diaz-Uriarte ramon-diaz at teleline.es
Fri Jan 12 19:54:08 CET 2001


On Fri, 12 Jan 2001, Witold Eryk Wolski wrote:
> HI!
> By xx[order(xx)] I can sort the array ascendin. How to sort them
> descending.
> 
> eg.:
> > a<-c(2,3,110,23,4)
> > a[order(a)]
> [1]   2   3   4  23 110
> 
> but i wont.
> [1] 110  23   4   3   2
> 


You can do:

a[order(-a)]


Ramón


-- 
Ramón Díaz-Uriarte
Triana 47
28016 Madrid
Spain

email:ramon-diaz at teleline.es
Phone: +-34-918-513-966
       +-34-657-186-407	







-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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