[R] obtaining null components of a list

jim holtman jholtman at gmail.com
Wed Jan 21 15:45:33 CET 2009


Try this:

> x <- list(NULL, 1:10, 25, NULL, "more")
> x
[[1]]
NULL

[[2]]
 [1]  1  2  3  4  5  6  7  8  9 10

[[3]]
[1] 25

[[4]]
NULL

[[5]]
[1] "more"

> which(sapply(x, is.null))
[1] 1 4
>


On Wed, Jan 21, 2009 at 7:42 AM, diego Diego <dhabbyc at gmail.com> wrote:
> Hello everybody!
>  I have a list of length 5000 whose components are (mostly) "ts" objects,
> but some these components are intentionally left empty, ie, they are "NULL"
> components of the list. My question is how can I get the position of these
> null components in a effective way (I'm trying to avoid a for-if rutine).
>
>
> Thanks!!!
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list