[R] Subsetting list of vectors with list of (boolean) vectors?
    Marc Schwartz 
    marc_schwartz at comcast.net
       
    Thu Apr 12 18:43:43 CEST 2007
    
    
  
On Thu, 2007-04-12 at 18:12 +0200, Johannes Graumann wrote:
> Dear Rologists,
> 
> I'm stuck with this. How would you do this efficiently:
> 
> > aPGI
> [[1]]
> [1] "864"  "5576"
> 
> 
> > aPGItest
> [[1]]
> [1]  TRUE FALSE
> 
> > result <- [magic box involving subset)
> 
> > result
> [[1]]
> [1] "864"
> 
> Thanks for any hints,
> 
> Joh
> lapply(seq(along = length(aPGI)), function(x) aPGI[[x]][aPGItest[[x]]])
[[1]]
[1] "864"
I think that this should be a generic solution for multiple (but common) levels in each list.
HTH,
Marc Schwartz
    
    
More information about the R-help
mailing list