Are any nonmissing values TRUE
any2.RdReturns TRUE if any nonmissing values in a logical vector are TRUE.
Details
Missing values are excluded before evaluation.
Compared with base::any(), any2() has stricter behavior:
any2()never returnsNA.any2()returnsFALSEfor non-logical input.any2()returnsFALSEforlogical(0)andNULL.
Examples
#----------------------------------------------------------------------------
# any2() examples
#----------------------------------------------------------------------------
library(bkbase)
x <- c(1, 2, 3, NA)
any2(x < 0)
#> [1] FALSE
any(x < 0, na.rm = TRUE)
#> [1] FALSE
any(x < 0, na.rm = FALSE)
#> [1] NA
any2(NA)
#> [1] FALSE
any(NA)
#> [1] NA
any2(1L)
#> [1] FALSE
any(1L)
#> [1] TRUE
any2(c(TRUE, NA))
#> [1] TRUE
any2(c(FALSE, NA))
#> [1] FALSE
any2(c(NA, NA))
#> [1] FALSE
any2(logical(0))
#> [1] FALSE
any(logical(0))
#> [1] FALSE
any2(NULL)
#> [1] FALSE
any(NULL)
#> [1] FALSE