Q:

How to use is.null() using brackets [] rather than the dollar sign $?

Fairly simple question. I am using is.null() in a loop to see if variables exist within many data frames.
is.null(mtcars$ddd)

TRUE

This works fine. But I need to insert the variables as text like this:
is.null(mtcars[, c("ddd")])

Error in `[.data.frame`(mtcars, , c("ddd")) : undefined columns selected

Is there any way to use the is.null() function while inserting the variable name as text?

A:

Use
is.null(mtcars[["ddd"]])

or
!hasName(mtcars, "ddd")

