Assert that an input is a vector/list with desired properties
assert_vector(
x,
class,
len = NULL,
null_ok = FALSE,
var_name = NULL,
subset_of = NULL,
named = FALSE,
n_call = -1L
)assert_list(x, len = NULL, null_ok = FALSE, named = FALSE)
assert_class(x, class, n_call = -1)
TRUE
if the check is successful. Throws an error describing the
issue with the input otherwise.
A vector/list. The input to be analysed.
A string. The class that this input should inherit from.
An integer. The length of the vector. If NULL
, length is not
checked.
A logical. Whether the input could also be NULL
.
A string. The name of the variable in the informative
message. If NULL
, the name is guessed from the function call.
A character vector. If x
is a character vector, specifies
which values it can take. If NULL
, values are not checked.
A logical. Whether the input should be a named vector/list. If
FALSE
this check is not enforced (i.e. the input object can be named even
if named is FALSE
).
A negative integer. The number of frames to go back to find the call to associate the error generated by the function with. Defaults to the parent frame (-1). This argument is only relevant to other assertion functions that build on top of this one.