[R] extracting components of a list

From: Robin Hankin <r.hankin_at_noc.soton.ac.uk>
Date: Tue 14 Jun 2005 - 00:23:21 EST


Hi

how do I extract those components of a list that satisfy a certain requirement? If

jj <- list(list(a=1,b=4:7),list(a=5,b=3:6),list(a=10,b=4:5))

I want just the components of jj that have b[1] ==4 which in this case would be the first and
third of jj, viz list (jj[[1]],jj[[3]]).

How to do this efficiently?

My only idea was to loop through jj, and set unwanted components to NULL, but
FAQ 7.1 warns against this.

--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

______________________________________________
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 Tue Jun 14 00:27:50 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:33 EST