Skip to contents

These functions work exactly the same as x == TRUE and x == FALSE but by default return FALSE for cases that are NA.

Usage

isTRUENA(x, ifNA = FALSE)

isFALSENA(x, ifNA = FALSE)

Arguments

x

Logical, or a condition that evaluates to logical, or a vector of logical values or conditions to evaluate.

ifNA

Logical, value to return if the result of evaluating x is NA. Note that this can be anything (i.e., TRUE, FALSE, a number, etc.).

Value

Logical or value specified in ifNA.

Functions

  • isFALSENA(): Vectorized test for truth robust to NA

See also

Examples

x <- c(TRUE, TRUE, FALSE, NA)
x == TRUE
#> [1]  TRUE  TRUE FALSE    NA
isTRUENA(x)
#> [1]  TRUE  TRUE FALSE FALSE
x == FALSE
#> [1] FALSE FALSE  TRUE    NA
isFALSENA(x)
#> [1] FALSE FALSE  TRUE FALSE
isTRUENA(x, ifNA = Inf)
#> [1]   1   1   0 Inf
# note that isTRUE and isFALSE are not vectorized
isTRUE(x)
#> [1] FALSE
isFALSE(x)
#> [1] FALSE