ago*_*dev 9 null r logical-operators
为什么是
isTRUE(NULL != 2)
[1] FALSE
Run Code Online (Sandbox Code Playgroud)
我怎么会收到真的?
在我的实际情况中,我有变量,我想处理一些东西,如果值不同.但是,当一个值为NULL时,我不认为它们是不同的!
Ron*_*hah 11
正如@Roland指出的那样,我们不能直接对NULL对象执行任何逻辑操作.为了比较它们,我们可能需要执行额外的检查,is.null然后执行逻辑比较.
我们可以使用它identical来比较处理整数的值NULL.
identical(4, 2)
#FALSE
identical(NULL, 2)
#FALSE
identical(2, 2)
#TRUE
Run Code Online (Sandbox Code Playgroud)