Learn R Programming

assertive (version 0.2-6)

assert_is_a_bool: Is the input logical?

Description

Checks to see if the input is logical.

Usage

assert_is_a_bool(x)

assert_is_logical(x)

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

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

Arguments

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

Value

  • is_logical wraps is.logical, providing more information on failure. is_a_bool returns TRUE if the input is logical and scalar. The assert_* functions return nothing but throw an error if the corresponding is_* function returns FALSE.

See Also

is.logical and is_scalar.

Examples

Run this code
assert_is_logical(runif(10) > 0.5)
assert_is_a_bool(TRUE)
assert_is_a_bool(NA)
#These examples should fail.
dont_stop(assert_is_logical(1))
dont_stop(assert_is_a_bool(c(TRUE, FALSE)))
dont_stop(assert_is_a_bool(logical()))

Run the code above in your browser using DataLab