Why is
isTRUE(NULL != 2)
[1] FALSE
And how would I receive TRUE?
In my real case I have variables and I want to process something, if the values differ. However, when one value is NULL I don't recognize them as different!
As @Roland pointed out, we can't perform any logical operations directly on NULL object. To compare them we might need to perform an additional check of is.null and then perform the logical comparison.
We can use identical instead to compare values which handles integers as well as NULL.
identical(4, 2)
#FALSE
identical(NULL, 2)
#FALSE
identical(2, 2)
#TRUE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With