is_null: Is the input (not) null?

Description Usage Arguments Value See Also Examples

View source: R/is-null.R

Description

Checks to see if the input is (not) null.

Usage

1
2
3
4
5
6
7
assert_is_not_null(x, severity = getOption("assertive.severity", "stop"))

assert_is_null(x, severity = getOption("assertive.severity", "stop"))

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

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

Arguments

x

Input to check.

severity

How severe should the consequences of the assertion be? Either "stop", "warning", "message", or "none".

.xname

Not intended to be used directly.

Value

is_null wraps is.null, providing more information on failure. is_not_null returns TRUE in the opposite case. The assert_* functions return nothing but throw an error if the corresponding is_* function returns FALSE.

See Also

is.null.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# Predicate for NULL. 
is_null(NULL)
is_null(c())

# Atomic vectors of length zero are not NULL!
is_null(numeric())
# ... and neither is NA
is_null(NA)

# The opposite check
is_not_null(NULL)
is_not_null(c())
is_not_null(numeric())

# These checks should pass
assert_is_null(NULL)
assert_is_null(c())
assert_is_not_null(NA)

# This should fail
assertive.base::dont_stop(assert_is_null(NaN))

assertive.properties documentation built on May 29, 2017, 6:12 p.m.