[R] removing NULL elements from a list
Prof Brian Ripley
ripley at stats.ox.ac.uk
Mon Apr 14 23:42:34 CEST 2003
On Mon, 14 Apr 2003, Vadim Ogranovich wrote:
> you can also modify the original list "in place":
>
> l[sapply(l, is.null)] <- NULL
>
>
> I don't understand why it works this way especially given that, for example,
>
> l[sapply(l, is.null)] <- 5
>
> simply replaces NULL elements of the list with 5. This probably has to do
> with the special semantics of NULL. I'd appreciate if someone could clearify
> this for me.
It's in the FAQ.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list