Skip to content
Prev 180876 / 398525 Next

exists function on list objects gives always a FALSE

?rout?k wrote:
'SmoothData$span' = 'foo'
    exists("SmoothData$span")
    # TRUE
'SmoothData[[2]]' = 'bar'
    exists("SmoothData[[2]]")
    # TRUE


the problem in your case is that you have an object named 'SmoothData'
with a nested component named 'span', but you're testing for the
existence of an object named 'SmoothData$span'. 

as shown in a recent post, one attempt to do your task would be

    exists('SmoothData') && 'span' %in% names(SmoothData)
    # TRUE

vQ