On Sat, 26-Aug-2006 at 09:57AM +0100, Patrick Burns wrote: |> > sub.m <- lapply(m, function(x)x[x>2]) |> > sub.m |> [[1]] |> [1] 3 4 |> |> [[2]] |> [1] 4 5 |> |> [[3]] |> [1] 4 |> |> > sub.m[unlist(lapply(sub.m, function(x) length(x) == 2))] |> [[1]] |> [1] 3 4 |> |> [[2]] |> [1] 4 5 |> |> > sub4.m <- lapply(m, function(x)x[x>4]) |> > sub4.m[unlist(lapply(sub4.m, function(x) length(x) > 0))] |> [[1]] |> [1] 5
Or slightly shorter in this case: sub.m[sapply(sub.m, function(x) length(x) == 2)] etc. -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___ Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_ Middle minds discuss events (:_~*~_:) Small minds discuss people (_)-(_) ..... Anon ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ______________________________________________ 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 and provide commented, minimal, self-contained, reproducible code.