Skip to content
Prev 139327 / 398506 Next

subset list based on logical within element flag

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=FALSE),
     list(gene.pair="Lgals1:Pxmp2", sig.cor=TRUE),
     list(gene.pair="Lgals1:Pxmp2", sig.cor=FALSE))
tmp <- lapply(gene.pair.tf.lst, function(x) if(x$sig.cor) x$gene.pair)
tmp[!sapply(tmp, is.null)]
On Wed, 12 Mar 2008, Mark W Kimpel wrote: