is_nan: Is the input (not) NaN?

Description Usage Arguments Value See Also Examples

Description

Checks to see if the input is a number that is(n't) NaN.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
assert_all_are_nan(x, severity = getOption("assertive.severity", "stop"))

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

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

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

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

is_not_nan(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_nan wraps is.nan, coercing the input to numeric if necessary. is_not_nan works similarly, but returns the negation. The assert_* functions return nothing but throw an error if the corresponding is_* function returns FALSE.

See Also

is.nan

Examples

1
2
3
4
5
6
x <- c(0, NaN, NA)
is_nan(x)
is_not_nan(x)
assert_all_are_not_nan(1:10)
assert_any_are_not_nan(x)
assertive.base::dont_stop(assert_all_are_not_nan(x))

Example output

There were 2 failures:
  Position Value    Cause
1        1     0 a number
2        3  <NA> a number
There was 1 failure:
  Position Value        Cause
1        2    NA not a number
$`assert_all_are_not_nan(x)`
<assertionError: is_not_nan : x contains NaNs.
There was 1 failure:
  Position Value        Cause
1        2    NA not a number>

assertive.numbers documentation built on May 2, 2019, 3:30 p.m.