Test if vector elements are empty

is_empty(x, ...)

Arguments

x

vector that may contain NA values.

...

additional arguments are ignored.

Details

This function simply checks if values in a vector are NA or "" with nchar(x) == 0.

For factor input, the values are coerced with as.character(). It might be slightly faster to test factor levels then to apply to the full vector.

Todo: Make this function work with list input, so it requires all elements to be is_empty().

See also

Examples

x1 <- c("A", "", NA, "B,C"); is_empty(x1)
#> [1] FALSE TRUE TRUE FALSE
is_empty(factor(x1))
#> [1] FALSE TRUE TRUE FALSE