[R] R: determination of number of entries in list elements

From: Guazzetti Stefano <Stefano.Guazzetti_at_ausl.re.it>
Date: Fri 19 May 2006 - 20:21:02 EST

You need lapply or sapply
for example:

sapply(yourlist, length)
then you can do
subset(yourlist, sapply(yourlist, length) > yourlength)


>-----Messaggio originale-----
>Da: r-help-bounces@stat.math.ethz.ch
>[mailto:r-help-bounces@stat.math.ethz.ch]Per conto di Benjamin Otto
>Inviato: 19 May, 2006 12:10
>A: R-Help
>Oggetto: [R] determination of number of entries in list elements
>is there some elegant way to determine the number of
>components stored in
>each list element?
>The list:
>> list
>[1] A B C
>[1] D
>[1] E F
>Then normal command "length(list)" would return 3. But I
>would like some
>command return the array of the single element lengths like
>[1] 3 1 2
>so I can afterwards get my list subset with only entries
>which have a
>certain amount of components bigger or lower than a certain
>R-help@stat.math.ethz.ch mailing list
>PLEASE do read the posting guide!

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri May 19 21:42:29 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 19 May 2006 - 22:10:15 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.