Checks if all missing values using
all(is.na(x))
Pass: NA, c(NA, NA), logical(0).
Fail: 1, 1:2, "1", c(1, NA).
Value
The chk_ function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The vld_ function returns a flag indicating whether the test was met.
See also
For more details about the use of this function,
please read the article
vignette("chk-families").
Other misc_checkers:
chk_join(),
chk_not_any_na(),
chk_not_empty(),
chk_unique()
Examples
# chk_all_na
try(chk_all_na(1))
#> Error in eval(expr, envir) : `1` must only have missing values.
try(chk_all_na(c(1, NA)))
#> Error in eval(expr, envir) : `c(1, NA)` must only have missing values.
chk_all_na(NA)
chk_all_na(c(NA, NA_character_, NA_real_))
# vld_all_na
vld_all_na(1)
#> [1] FALSE
vld_all_na(1:2)
#> [1] FALSE
vld_all_na(NA_real_)
#> [1] TRUE
vld_all_na(integer(0))
#> [1] TRUE
vld_all_na(c(NA, 1))
#> [1] FALSE
vld_all_na(TRUE)
#> [1] FALSE
vld_all_na(c(NA_real_, NA_character_))
#> [1] TRUE
