Re: [R] subset list based on logical within element flag

2008-03-12 Thread Christos Hatzis
nesday, March 12, 2008 6:53 PM > To: Benilton Carvalho; [EMAIL PROTECTED] > Cc: R Help > Subject: Re: [R] subset list based on logical within element flag > > Hi I have the smililar question. > > I have a list: > my_list <- list(name="Fred", wife="Mary&qu

Re: [R] subset list based on logical within element flag

2008-03-12 Thread Srinivas Iyyer
Hi I have the smililar question. I have a list: my_list <- list(name="Fred", wife="Mary", no.children=3, child.ages=c(4,7,9)) > my_list $name [1] "Fred" $wife [1] "Mary" $no.children [1] 3 $child.ages [1] 4 7 9 Now I want to search "Fred" and get attribute of that value which is 'name'.

Re: [R] subset list based on logical within element flag

2008-03-12 Thread Prof Brian Ripley
I'm not sure exactly what you want, but try something like lapply(gene.pair.tf.lst, function(x) if(x$sig.cor) x$gene.pair) If you only want the non-NULL entries (and how would you know which they are, given you have duplicates?) gene.pair.tf.lst <- list(list(gene.pair="Lgals1:Pxmp2", sig.cor=FA

Re: [R] subset list based on logical within element flag

2008-03-12 Thread Benilton Carvalho
gene.pair.tf.lst[sapply(gene.pair.tf.lst, "[[", "sig.cor")] b On Mar 12, 2008, at 5:24 PM, Mark W Kimpel wrote: I have a very long list that I'd like to subset based on a logical value within each element. Example below. I'd like to get just those list elements for further study whose $sig.