Check if argument is of proper class.
check_class(x, arg_class, alt_null = FALSE, add_msg = NULL)
If argument class
is same as arg_class
it returns invisible
NULL
. Otherwise the function throws an error.
Function argument that is being asserted.
Class name. Usually "character", "numeric", "data.frame", etc.
Logical. Should argument accept NULL value.
Is an additional message that can be printed over the standard function error message. You can:
pass the names of the arguments that failed the test by using
{x_names}
in the message body (e.g. "What are the {x_names}");
pass the tested class by using {arg_class}
in the message body (e.g.
"I want them to be {arg_class})"
pass the classes of the arguments that failed the test by using
{wrong_class}
in the message body (e.g. "{wrong_class} is wrong")