Is the input atomic/recursive/vector?

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))
Input to check.
How severe should the consequences of the assertion be? Either "stop", "warning", "message", or "none".
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.

See Also

is.atomic and is.vector.

  • assert_is_atomic
  • assert_is_nested
  • assert_is_non_nested
  • assert_is_recursive
  • assert_is_vector
  • is_atomic
  • is_nested
  • is_non_nested
  • is_recursive
  • is_vector
library( 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 <-"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)
Documentation reproduced from package, version 0.0-4, License: GPL (>= 3)

Community examples

Looks like there are no examples yet.