[R] Lowest k values of list

David Winsemius dwinsemius at comcast.net
Fri Sep 5 18:03:40 CEST 2008


On Sep 5, 2008, at 11:26 AM, Markus Mühlbacher wrote:

> 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.


Might depend on how you define "high" and "low". Consider these  
experiments:

 > z <- list(1,4,"5",6,,2,3)
 > head(sort(unlist(z)),n=2)
[1] "1" "2"
 > tail(sort(unlist(z)),n=2)
[1] "5" "6"


 > z <- list(1,2,3,4,"5",6,"a")
 > tail(sort(unlist(z)),n=2)
[1] "6" "a"
 > head(sort(unlist(z)),n=2)
[1] "1" "2"



-- 
David Winsemius



More information about the R-help mailing list