vec_assert {vctrs} | R Documentation |
vec_is()
is a predicate that checks if its input conforms to a
prototype and/or a size.
vec_assert()
throws an error when the input doesn't conform.
vec_assert(x, ptype = NULL, size = NULL, arg = as_label(substitute(x))) vec_is(x, ptype = NULL, size = NULL)
x |
A vector argument to check. |
ptype |
Prototype to compare against. If the prototype has a
class, its |
size |
Size to compare against |
arg |
Name of argument being checked. This is used in error
messages. The label of the expression passed as |
vec_is()
returns TRUE
or FALSE
. vec_assert()
either
throws a typed error (see section on error types) or returns x
,
invisibly.
If the prototype doesn't match, an error of class
"vctrs_error_assert_ptype"
is raised.
If the size doesn't match, an error of class
"vctrs_error_assert_size"
is raised.
Both errors inherit from "vctrs_error_assert"
.