assert_is_a_double {assertive.types}R Documentation

Is the input numeric?

Description

Checks to see if the input is numeric.

Usage

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

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

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

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

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

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

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

is_numeric(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_numeric wraps is.numeric, providing more information on failure. is_a_number returns TRUE if the input is numeric and scalar. The assert_* functions return nothing but throw an error if the corresponding is_* function returns FALSE.

Note

numeric means either double or integer, inc this case.

See Also

is_integer, is.numeric and is_scalar.

Examples

# "numeric" fns work on double or integers; 
assert_is_numeric(1:10)

# Here we check for length 1 as well as type
assert_is_a_number(pi)
assert_is_a_number(1L)
assert_is_a_number(NA_real_)

# "double" fns fail for integers.
assert_is_a_double(pi)

#These examples should fail.
assertive.base::dont_stop(assert_is_numeric(c(TRUE, FALSE)))
assertive.base::dont_stop(assert_is_a_number(1:10))
assertive.base::dont_stop(assert_is_a_number(numeric()))
assertive.base::dont_stop(assert_is_double(1:10))

[Package assertive.types version 0.0-3 Index]