I would like to test if an element of a list exists, here is an example
foo <- list(a=1)
TRUE #foo does exist
FALSE #suggests that foo$a does not exist
 1 #but it does exist
In this example, I know that foo$a exists, but the test returns FALSE.
I looked in ?exists and have found that with(foo, exists('a') returns TRUE, but do not understand why exists('foo$a') returns FALSE.
- Why does exists('foo$a') return FALSE?
- Is use of with(...) the preferred approach?