assertive.numbers (version 0.0-2)

assert_all_are_finite: Are the inputs (in)finite?

Description

Checks to see if the inputs are (in)finite.

Usage

assert_all_are_finite(x, severity = getOption("assertive.severity", "stop"))
assert_any_are_finite(x, severity = getOption("assertive.severity", "stop"))
assert_all_are_infinite(x, severity = getOption("assertive.severity", "stop"))
assert_any_are_infinite(x, severity = getOption("assertive.severity", "stop"))
assert_all_are_negative_infinity(x, severity = getOption("assertive.severity", "stop"))
assert_any_are_negative_infinity(x, severity = getOption("assertive.severity", "stop"))
assert_all_are_positive_infinity(x, severity = getOption("assertive.severity", "stop"))
assert_any_are_positive_infinity(x, severity = getOption("assertive.severity", "stop"))
is_finite(x, .xname = get_name_in_parent(x))
is_infinite(x, .xname = get_name_in_parent(x))
is_negative_infinity(x, .xname = get_name_in_parent(x))
is_positive_infinity(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_finite wraps is.finite, showing the names of the inputs in the answer. is_infinite works likewise for is.infinite. The assert_* functions return nothing but throw an error if the corresponding is_* function returns FALSE.

See Also

is.finite

Examples

Run this code
x <- c(0, Inf, -Inf, NA, NaN)
is_finite(x)
is_infinite(x)
is_positive_infinity(x)
is_negative_infinity(x)
assert_all_are_finite(1:10)
assert_any_are_finite(c(1, Inf))
assert_all_are_infinite(c(Inf, -Inf))
assertive.base::dont_stop(assert_all_are_finite(c(0, Inf, -Inf, NA, NaN)))

Run the code above in your browser using DataLab