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(bar=NULL) is.null(foo$bar) # TRUE is.null(foo$foo) # TRUE i must admit i find it surprising that ?'$' does not appropriately explain what happens if a list is indexed with a name not included in the list's names. the closest is " When extracting, a numerical, logical or character 'NA' index picks an unknown element and so returns 'NA' in the corresponding element of a logical, integer, numeric, complex or character result, and 'NULL' for a list. " but it's valid for NAs in the index, and " If no match is found then 'NULL' is returned. " but it's in the section on environments. 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.