Although R allows arbitrary-level access to lists, this does not (yet) extend to call
objects or certain other language objects-- hence these functions. They are written entirely in R, and are probably very slow as a result. Notwithstanding EXAMPLES below, it is unwise to replace system [[
and [[<-
with these replacements at a global level, i.e. outside the body of a function-- these replacements do not dispatch based on object class, for example.
Note that my.index
and my.index.assign
distort strict R syntax, by concatenating their ...
arguments before lookup. Strictly speaking, R says that x[[2,1]]
should extract one element from a matrix list; however, this doesn't really seem useful because the same result can always be achieved by x[2,1][[1]]
. With my.index
, x[[2,1]]
is the same as x[[c(2,1)]]
. The convenience of automatic concatentation seemed slightly preferable (at least when I wrote these, in 2001).
my.index.exists
checks whether var
is "deep enough" for var[[i]]
to work. Unlike the others, it does not automatically concatenate indices.
At present, there is no facility to use a mixture of character and numeric indexes, which you can in S+ via "list subscripting of lists".