From macrakis at alum.mit.edu  Sun Mar 15 19:31:43 2009
From: macrakis at alum.mit.edu (Stavros Macrakis)
Date: Sun, 15 Mar 2009 14:31:43 -0400
Subject: [Rd] Definition of [[
Message-ID: <8b356f880903151131j53765d2fo5aaa8a84dc971817@mail.gmail.com>

The semantics of [ and [[ don't seem to be fully specified in the
Reference manual.  In particular, I can't find where the following
cases are covered:

> cc <- c(1); ll <- list(1)

> cc[3]
[1] NA
OK, RefMan says: If i is positive and exceeds length(x) then the
corresponding selection is NA.

> dput(ll[3])
list(NULL)
? i is positive and exceeds length(x); why isn't this list(NA)?

> ll[[3]]
Error in list(1)[[3]] : subscript out of bounds
? Why does this return NA for an atomic vector, but give an error for
a generic vector?

> cc[[3]] <- 34; dput(cc)
c(1, NA, 34)
OK

ll[[3]] <- 34; dput(ll)
list(1, NULL, 34)
Why is second element NULL, not NA?
And why is it OK to set an undefined ll[[3]], but not to get it?

I assume that these are features, not bugs, but I can't find
documentation for them.

            -s



[Rd] Definition of [[
Stavros Macrakis