Learn R Programming

stratallo (version 3.0.1)

obj_emptiness: Object Emptiness (NULL or zero-length)

Description

[Stable]

Utility functions for checking whether an object is empty, where emptiness is defined as being NULL or having length 0.

Usage

is_empty(x)

is_nonempty(x)

Arguments

x

object to test.

Functions

  • is_empty(): Returns TRUE if the object is NULL or has length 0, and FALSE otherwise.

  • is_nonempty(): Logical negation of is_empty(). This function directly checks if length(x) > 0L for performance reasons, avoiding the extra negation step that would occur if using !is_empty(x). It is optimized for repeated use in algorithms where is_nonempty() is called many times.

Examples

Run this code
# internal functions (not exported) – examples skipped

if (FALSE) {
is_empty(NULL)
is_empty(character(0))
is_empty(1)
}

if (FALSE) {
is_nonempty(NULL)
is_nonempty(character(0))
is_nonempty(1)
}

Run the code above in your browser using DataLab