| assert_is_a_double {assertive.types} | R Documentation |
Checks to see if the input is numeric.
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))
x |
Input to check. |
severity |
How severe should the consequences of the assertion be?
Either |
.xname |
Not intended to be used directly. |
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.
numeric means either double or integer, inc this case.
is_integer, is.numeric and
is_scalar.
# "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))