[R] exists function on list objects gives always a FALSE
murdoch at stats.uwo.ca
Tue May 19 18:31:55 CEST 2009
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)
>  TRUE
>  0.001
> Thank you for any opinion regarding this topic.
There is no variable with name "SmoothData$span", there is an element of
SmoothData with name "span".
To test for that, the safest test is probably
"span" %in% names(SmoothData)
but a common convention is to use
because NULL elements are rare in lists.
More information about the R-help