View source: R/is-atomic-recursive-vector.R
assert_is_atomic | R Documentation |
Checks to see if the input is a type that is atomic/recursive/vector.
assert_is_atomic(x, severity = getOption("assertive.severity", "stop")) assert_is_nested(x, severity = getOption("assertive.severity", "stop")) assert_is_non_nested(x, severity = getOption("assertive.severity", "stop")) assert_is_recursive(x, severity = getOption("assertive.severity", "stop")) assert_is_vector(x, severity = getOption("assertive.severity", "stop")) is_atomic(x, .xname = get_name_in_parent(x)) is_nested(x, .xname = get_name_in_parent(x)) is_non_nested(x, .xname = get_name_in_parent(x)) is_recursive(x, .xname = get_name_in_parent(x)) is_vector(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_atomic
, is_recursive
and is_vector
wrap
is.atomic
, is.recursive
and is.vector
respectively,
providing more information on failure.
is_nested
checks for recursive objects where at least one element is
also recursive. is_non_nested
returns TRUE
for atomic objects
and recursive objects where no elements are recursive.
The assert_*
functions return nothing but throw an error if the
corresponding is_*
function returns FALSE
.
is.atomic
and is.vector
.
atomic_types <- list( logical(), integer(), numeric(), complex(), character(), raw(), matrix(), array(), factor(), NULL ) for(var in atomic_types) assert_is_atomic(var) recursive_types <- list( list(), expression(), data.frame(), y ~ x, function(){}, call("sin", "pi") ) for(var in recursive_types) assert_is_recursive(var) # Names are neither atomic nor recursive a_name <- as.name("x") is_atomic(a_name) is_recursive(a_name) vector_types <- c( atomic_types[1:6], recursive_types[1:2] ) for(var in vector_types) assert_is_vector(var) # Nested objects are recursive and have at least one recursive element nested_list <- list(a = 1, b = list(2:3)) assert_is_nested(nested_list) for(elt in nested_list) assert_is_non_nested(elt)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.