View source: R/utils_validation.R
| is_empty | R Documentation |
This lightweight helper mimics the behaviour of 'pracma::isempty()' but depends only on base R. An object is considered *empty* when it contains no data: * 'NULL' * an atomic vector, matrix, array or factor of length 0 * a list (including named lists) of length 0 * a data frame with zero rows ('nrow == 0')
is_empty(x)
x |
Any R object. |
The function is deliberately strict - environments, functions, S4/R6 objects, etc. are **not** treated as empty. If you need additional classes to be regarded as empty you can extend the internal checks.
A logical scalar ('TRUE' if 'x' is empty, 'FALSE' otherwise).
## Not run:
is_empty(NULL) # TRUE
is_empty(numeric(0)) # TRUE
is_empty(list()) # TRUE
is_empty(data.frame()) # TRUE
is_empty(1:5) # FALSE
is_empty(list(a = 1)) # FALSE
is_empty(data.frame(x = 1)) # FALSE
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.