[R] How to detect NULL list element?

rkevinburton at charter.net rkevinburton at charter.net
Mon Nov 3 08:54:48 CET 2008


I have a list that starts out like:

r <- list()
r[[3]] <- list(count=1, orderlist=data.frame(count=1, sku="A"))

So r[3] yeilds:

[[1]]
[[1]]$count
[1] 1

[[1]]$orderlist
  count sku
1     1   A

So far so good. Now I want to detect the fact that there is no etry in 1,2, and 4.

> r[1]
[[1]]
NULL
> is.null(r[1])
[1] FALSE

So how do I detect the NULL at r[1]?

Thank you.

Kevin



More information about the R-help mailing list