Re: [R] exists function on list objects gives always a FALSE

2009-05-19 Thread Wacek Kusnierczyk
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 name

Re: [R] exists function on list objects gives always a FALSE

2009-05-19 Thread Stavros Macrakis
On Tue, May 19, 2009 at 12:07 PM, Žroutík 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 *alway

Re: [R] exists function on list objects gives always a FALSE

2009-05-19 Thread Wacek Kusnierczyk
Linlin Yan wrote: > SmoothData$span is not an object which can be checked by exists(), but > part of an object which can be checked by is.null(). > > is.null is unhelpful here, in that lists can contain NULL as a named element, and retrieving a non-existent element returns NULL: foo = list

Re: [R] exists function on list objects gives always a FALSE

2009-05-19 Thread Wacek Kusnierczyk
Žroutík wrote: > >> SmoothData <- list(exists=TRUE, span=0.001) >> SmoothData >> > $exists > [1] TRUE > > $span > [1] 0.001 > > >> exists("SmoothData") >> > TRUE > > >> exists("SmoothData$span") >> > FALSE > > 'SmoothData$span' = 'foo' exists("SmoothData$span")

Re: [R] exists function on list objects gives always a FALSE

2009-05-19 Thread Romain Francois
Žroutík wrote: Dear R-users, in a minimal example exists() gives FALSE on an object which obviously does exist. How can I check on that list object anyway else, please? SmoothData <- list(exists=TRUE, span=0.001) SmoothData $exists [1] TRUE $span [1] 0.001 exists("SmoothData")

Re: [R] exists function on list objects gives always a FALSE

2009-05-19 Thread Duncan Murdoch
On 5/19/2009 12:07 PM, Žroutík wrote: Dear R-users, in a minimal example exists() gives FALSE on an object which obviously does exist. How can I check on that list object anyway else, please? SmoothData <- list(exists=TRUE, span=0.001) SmoothData $exists [1] TRUE $span [1] 0.001 exists("Sm

Re: [R] exists function on list objects gives always a FALSE

2009-05-19 Thread Linlin Yan
SmoothData$span is not an object which can be checked by exists(), but part of an object which can be checked by is.null(). On Wed, May 20, 2009 at 12:07 AM, Žroutík wrote: > Dear R-users, > > in a minimal example exists() gives FALSE on an object which obviously does > exist. How can I check on

[R] exists function on list objects gives always a FALSE

2009-05-19 Thread Žroutík
Dear R-users, in a minimal example exists() gives FALSE on an object which obviously does exist. How can I check on that list object anyway else, please? > SmoothData <- list(exists=TRUE, span=0.001) > SmoothData $exists [1] TRUE $span [1] 0.001 > exists("SmoothData") TRUE > exists("SmoothData