Learn R Programming

evanverse (version 0.3.7)

is_void: is_void(): Check for Null / NA / Blank ("") Values

Description

Determine whether input values are considered "void": NULL, NA, or "". Each condition is controlled by a dedicated argument.

Usage

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

Value

A logical vector indicating which elements are void.

  • If x is NULL, returns a single TRUE (if include_null=TRUE) or FALSE.

  • If x is an empty vector, returns logical(0).

  • If x is a list, evaluates each element recursively and returns a flattened logical vector.

  • For atomic vectors, returns a logical vector of the same length.

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.

Examples

Run this code
is_void(c(NA, "", "text"))                  # TRUE TRUE FALSE
is_void(list(NA, "", NULL, "a"))            # TRUE TRUE TRUE FALSE
is_void("NA", include_na = FALSE)           # FALSE
is_void(NULL)                               # TRUE

Run the code above in your browser using DataLab