Does the input have elements?
Usage
hasElements(x, n = NULL)
nElements(x)
Arguments
- x
Object.
- n
integer(1).
Number to include.
Value
TRUE on success;
FALSE on failure, with cause set.
See also
prod(), which returns the product of all values in its arguments. This
is called internally to check the number of elements.
assertive.properties::has_elements().
assertive.properties::is_of_dimension().
assertive.properties:::n_elements().
Examples
## TRUE ====
hasElements("hello")
#> [1] TRUE
hasElements("hello", n = 1)
#> [1] TRUE
hasElements(list(a = 1, b = 2), n = 2)
#> [1] TRUE
## FALSE ====
hasElements(NULL)
#> [1] FALSE
hasElements(list(), n = 1)
#> [1] FALSE