ez.is.empty: Empty Value

View source: R/basic.R

ez.is.emptyR Documentation

Empty Value

Description

Rails-inspired helper that checks if vector values are "empty", i.e. if it's: NULL, zero-length, NA, NaN, FALSE, an empty string. Note that unlike its native R is.<something> sibling functions, is.empty is vectorised (hence the "values").

Usage

ez.is.empty(x, trim = TRUE, ...)

Arguments

x

an object to check its emptiness

trim

trim whitespace? (TRUE by default)

...

additional arguments for sapply

Value

a logical vector (vectorized).

Note

copied from https://cran.r-project.org/web/packages/rapportools/index.html

Examples

## Not run: 
is.empty(NULL)     # [1] TRUE
is.empty(c())      # [1] TRUE
is.empty(NA)       # [1] TRUE
is.empty(NaN)      # [1] TRUE
is.empty("")       # [1] TRUE
is.empty(0)        # [1] TRUE --> (\code{0} jerry changed to FALSE)
is.empty(0.00)     # [1] TRUE --> (\code{0} jerry changed to FALSE)
is.empty("    ")   # [1] TRUE
is.empty("foobar") # [1] FALSE
is.empty("    ", trim = FALSE)    # [1] FALSE
# is.empty is vectorised!
all(is.empty(rep("", 10)))        # [1] TRUE
all(is.empty(matrix(NA, 10, 10))) # [1] TRUE

## End(Not run)

jerryzhujian9/zmisc documentation built on March 9, 2024, 12:49 a.m.