Learn R Programming

assertive (version 0.1-7)

assert_is_empty: Is the input empty/scalar?

Description

Checks to see if the input has length zero/one.

Usage

assert_is_empty(x)

  assert_is_non_empty(x)

  assert_is_scalar(x)

  is_empty(x, .xname = get_name_in_parent(x))

  is_non_empty(x, .xname = get_name_in_parent(x))

  is_scalar(x, .xname = get_name_in_parent(x))

Arguments

x
Input to check.
.xname
Not intended to be used directly.

Value

  • is_empty returns TRUE if the input has length zero. is_scalar returns TRUE if the input has length one. The assert_* functions return nothing but throw an error if the corresponding is_* function returns FALSE.

See Also

length.

Examples

Run this code
assert_is_empty(NULL)
assert_is_empty(numeric())
assert_is_non_empty(1:10)
assert_is_non_empty(NA)
assert_is_scalar(1)
assert_is_scalar("Multiple words in a single string are scalar.")
assert_is_scalar(NA)

Run the code above in your browser using DataLab