Skip to contents

Test whether any element in a vector or list is considered "void". Void values include NA, NULL, and empty strings (""), and you can customize which ones to consider.

Usage

any_void(x, include_na = TRUE, include_null = TRUE, include_empty_str = TRUE)

Arguments

x

A vector or list to evaluate.

include_na

Logical. Consider NA as void. Default: TRUE.

include_null

Logical. Consider NULL as void. Default: TRUE.

include_empty_str

Logical. Consider "" as void. Default: TRUE.

Value

A single logical value:

  • TRUE if any void values are present.

  • FALSE otherwise.

  • For NULL input, returns TRUE if include_null = TRUE, else FALSE.

Examples

any_void(c("a", "", NA))                # TRUE
#> [1] TRUE
any_void(list("x", NULL, "y"))          # TRUE
#> [1] TRUE
any_void(c("a", "b", "c"))              # FALSE
#> [1] FALSE
any_void(NULL)                          # TRUE
#> [1] TRUE
any_void("", include_empty_str = FALSE) # FALSE
#> [1] FALSE