如何使用方括号[]而不是美元符号$使用is.null()?

非常简单的问题。我在循环中使用is.null()来查看变量是否存在于许多数据帧中。

is.null(mtcars$ddd)

TRUE

这很好。但是我需要像这样将变量插入为文本:

is.null(mtcars[,c("ddd")])

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

在将变量名作为文本插入时,有什么方法可以使用is.null()函数吗?

lite840 回答:如何使用方括号[]而不是美元符号$使用is.null()?

使用

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

!hasName(mtcars,"ddd")
本文链接:https://www.f2er.com/3113911.html

大家都在问