removing NULL elements from a list
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. Thanks, Vadim
-----Original Message----- From: Peter Dalgaard BSA [mailto:p.dalgaard at biostat.ku.dk] Sent: Monday, April 14, 2003 10:07 AM To: Peter Dalgaard BSA Cc: R-Help (E-mail); Ramon Diaz Subject: Re: [R] removing NULL elements from a list Peter Dalgaard BSA <p.dalgaard at biostat.ku.dk> writes:
l <- l[!lapply(l,is.null)]
... sapply, of course, as Brian and Uwe said. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
--------------------------------------------------
DISCLAIMER\ This e-mail, and any attachments thereto, is intende... {{dropped}}