Dear Markus,
I think that I missed something in my previous reply. Here is another
approach using the first k values of each list:
# Data set
set.seed(123)
mylist=list(a=rnorm(10),b=rpois(15,10),f=rnorm(30,12,3))
# Function to report the first k values
k.values=function(x,k){
res= x[order(x)][1:k]
names(res)=paste('value_',1:k,sep="")
res
}
# Example: first 3 values
res=lapply(mylist,k.values,k=3)
do.call(rbind,res)
value_1 value_2 value_3
a -1.265061 -0.6868529 -0.5604756
b 3.000000 4.0000000 6.0000000
f 7.353742 8.2038109 8.5855892
HTH,
Jorge
On Fri, Sep 5, 2008 at 11:26 AM, Markus Mühlbacher <[EMAIL PROTECTED]>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.
>
> Best wishes,
> Markus
>
>
>
>
> ______________________________________________
> [email protected] 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.
>
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.