[R] removing NULL elements from a list
Uwe Ligges
ligges at statistik.uni-dortmund.de
Mon Apr 14 17:04:05 CEST 2003
Ramon Diaz wrote:
> Dear All,
>
> I have a list, where several components are NULL, and I'd like to obtain that
> very same list without the NULL components (i.e., I do not want to unlist or
> otherwise loose the rest of the list structure). I can do that with a loop,
> but how could I do it without a loop?
For a list L:
L[!sapply(L, is.null)]
Uwe Ligges
More information about the R-help
mailing list