Does the input have elements?

hasElements(x, n = NULL, .xname = getNameInParent(x))

nElements(x)

Arguments

x

Object.

n

integer(1). Number to include.

.xname

Name of object defined in x. Not intended to be used directly.

Value

TRUE on success; FALSE on failure, with cause set.

Functions

  • nElements: Return the number of elements in object.

Note

Updated 2019-10-04.

See also

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 #> Cause: 'NULL' has 0 elements.
hasElements(list(), n = 1)
#> [1] FALSE #> Cause: 'list()' has 0 elements, not 1.