Does the input have elements?
hasElements(x, n = NULL, .xname = getNameInParent(x)) nElements(x)
x | Object. |
---|---|
n |
|
.xname | Name of object defined in |
TRUE
on success;
FALSE
on failure, with cause set.
nElements
: Return the number of elements in object.
Updated 2019-10-04.
prod()
, which returns the product of all values in its arguments. This
is called internally to check the number of elements.
assertive.properties:::n_elements()
.
## TRUE ==== hasElements("hello")#> [1] TRUEhasElements("hello", n = 1)#> [1] TRUE#> [1] TRUE## FALSE ==== hasElements(NULL)#> [1] FALSE #> Cause: 'NULL' has 0 elements.#> [1] FALSE #> Cause: 'list()' has 0 elements, not 1.