sorting ascending descending! & THX@coling
Thomas Vogels <tov at ece.cmu.edu> writes:
Witold Eryk Wolski <wolski at molgen.mpg.de> writes:
THX. You are right!! a[order(-1*a)] [1] 110 23 4 3 2 Eryk
hmm, I would have thought rev(order(...)) to be more intuitive: x[order(x)] sorts in ascending order, x[rev(order(x))] sorts in descending order...
It is, but the sign trick generalizes to multiple sort criteria: d[order(d$sex,-d$year,-rank(d$ch)),] (assuming that d$ch is a character vector which you want to sort by in reverse alphabetical order).
O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._