[R] which.max2()

Esmail Bonakdarian esmail.js at gmail.com
Fri May 9 19:24:25 CEST 2008


Dimitris Rizopoulos wrote:
> try this:
> 
> v <- rnorm(10)
> v
> order(v, decreasing = TRUE)[1:2]

Wow .. that is slick! First I thought, wait .. I don't want to
reorder the elements, but this doesn't - it just returns the index
values in order. I don't really get that from reading the documentation,
it's probably there, but not that clear to me.

Thanks for showing me something more "R'ish".

Esmail



More information about the R-help mailing list