On Tue, May 19, 2009 at 12:07 PM, Žroutík <zroutik@gmail.com> wrote:

> > SmoothData <- list(exists=TRUE, span=0.001)
> > exists("SmoothData$span")
> FALSE
>

As others have said, this just checks for the existence of a variable with
the (strange) name "SmoothData$span".

In some sense, in R semantics, xxx$yyy *always* exists if xxx is a list (or
other recursive object):

     > xxx <- list()
     > xxx$hello
     NULL

You might think that you can check names(xxx) to see if the slot has been
explicitly set, but it depends on *how* you have explicitly set the slot to
NULL:

   > xxx$hello <- 3
   > xxx$hello <- NULL
   > names(xxx)
   character(0)                  # no names -- assigning to NULL kills slot
   > xxx <- list(hello=NULL)
   > names(xxx)
   [1] "hello"                    # 1 name -- constructing with NULL-valued
slot

Welcome to R!

            -s

	[[alternative HTML version deleted]]


