I would like to access an element from a list but I got NULL
> x <- list("b" = TRUE)
> x
$b
[1] TRUE
> x$b
[1] TRUE
> var=c("b","c")
I tried this:
> x$var[1]
NULL
We can use [[
instead of $
as $
would try to literally search for var
as the list
name instead of the value stored in the object
x[[var[1]]]
#[1] TRUE