[R] Lowest k values of list

Greg Snow Greg.Snow at imail.org
Fri Sep 5 18:54:48 CEST 2008


In addition to the other responses, you may want to look at the 'partial' argument to sort.  For large vectors it may speed things up to not sort everything if all you care about is the top and bottom few.

Try:

> tmp <- rnorm(100)
> plot( sort(tmp, partial=c(1,2,99,100) ) )

Hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
(801) 408-8111



> -----Original Message-----
> From: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] On Behalf Of Markus Mühlbacher
> Sent: Friday, September 05, 2008 9:26 AM
> To: r-help at r-project.org
> Subject: [R] Lowest k values of list
>
> Hi @ all,
>
> how do I get the largest or lowest k values of list? It must
> similar to the min() / max() function, but I just don't get it.
>
> Best wishes,
> Markus
>
>
>
>
> ______________________________________________
> R-help at r-project.org 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.
>



More information about the R-help mailing list