Stavros Macrakis wrote:
>
> 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
>   

kills indeed:

    foo = list(bar=1)

    with(foo, bar)
    # 1

    foo$bar = NULL
    with(foo, bar)
    # error: object 'bar' not found

>    > xxx <- list(hello=NULL)
>    > names(xxx)
>    [1] "hello"                    # 1 name -- constructing with NULL-valued
> slot
>   

but:

    # cleanup -- don't do it in mission critical session
    rm(list=ls())

    foo
    # error: object 'foo' not found

    foo = NULL
    foo
    # NULL

that is, foo$bar = NULL kills bar within foo (even though NULL is a
valid component of lists), but foo = NULL does *not* kill foo.

> Welcome to R!
>   

... and its zemanticks.

vQ

______________________________________________
R-help@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.

Reply via email to