Is there a boolean opperator that gives me NA
if any of the parts is NA
?
Currently
NA & FALSE == FALSE
FALSE & NA == FALSE
NA & TRUE == NA
TRUE & NA == NA
I'd like to have:
NA x FALSE == NA
FALSE x NA == NA
PS:
I'm searching for an operator x for which
x | a=TRUE | =FALSE | =NA
-----------------------------------
b=TRUE | TRUE | FALSE | NA
=FALSE | FALSE | FALSE | NA
=NA | NA | NA | NA
so I could do
result <- a x b
You could define your own operator that does what you want.
> `%and%` <- function(x, y){as.logical(x*y)}
> NA %and% FALSE
[1] NA
> FALSE %and% NA
[1] NA
> NA %and% TRUE
[1] NA
> TRUE %and% NA
[1] NA
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