« Return to Thread: which.max2()

Re: which.max2()

by Esmail Bonakdarian-4 :: Rate this Message:

Reply to Author | View in Thread

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

______________________________________________
R-help@... mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

 « Return to Thread: which.max2()