Guazzetti Stefano
2006-May-19 10:21 UTC
[R] R: determination of number of entries in list elements
You need lapply or sapply for example: sapply(yourlist, length) then you can do subset(yourlist, sapply(yourlist, length) > yourlength) Stefano >-----Messaggio originale----- >Da: r-help-bounces at stat.math.ethz.ch >[mailto:r-help-bounces at 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 > > >Hi, > >is there some elegant way to determine the number of >components stored in >each list element? > >Example: > >The list: >--------- >> list > >$Elem1 >[1] A B C > >$Elem1 >[1] D > >$Elem1 >[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 >threshold. > >regards > >Benjamin > >______________________________________________ >R-help at 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 > >