[R] Lowest k values of list
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.
> tmp <- rnorm(100)
> plot( sort(tmp, partial=c(1,2,99,100) ) )
Hope this helps,
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
greg.snow at imail.org
> -----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,
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help