A set of convenience functions for checking objects/arguments to a function passed by a user.
check_bool(
x,
name,
check_length = 1,
allow_NULL = FALSE,
allow_NA = TRUE,
call = ""
)
check_char(
x,
name,
check_length = 1,
allow_values = NULL,
allow_NULL = FALSE,
allow_NA = TRUE,
call = ""
)
check_real(
x,
name,
lower = -Inf,
upper = Inf,
allow_bound = TRUE,
check_length = 1,
allow_NULL = FALSE,
allow_NA = TRUE,
call = ""
)
check_int(
x,
name,
lower = -Inf,
upper = Inf,
allow_bound = TRUE,
check_length = 1,
allow_NULL = FALSE,
allow_NA = TRUE,
call = ""
)
check_list(
x,
name,
check_length = 0,
check_names = NULL,
all_objects = FALSE,
allow_other = FALSE,
allow_NULL = FALSE,
call = ""
)object to be checked
name of the object that will be print in the error message.
length of the object to be checked. Defaults to
1. Set to 0 in order to not check object length.
whether the object can be NULL.
If so, no checks are executed.
whether the object can contain NA or NaN
values.
string to be placed as a prefix to the error call.
names of values allowed in a character vector.
Defaults to NULL (do not check).
lower bound of allowed values.
Defaults to -Inf (do not check).
upper bound of allowed values.
Defaults to Inf (do not check).
whether the values at the boundary are allowed.
Defaults to TRUE.
names of entries allowed in a list. Defaults to
NULL (do not check).
whether all entries in check_names must be
present. Defaults to FALSE.
whether additional entries then the specified in
check_names might be present
returns NULL, called for the input check.
# check whether the object is logical
check_bool(TRUE, name = "input")
#> NULL
# will throw an error on any other type
if (FALSE) { # \dontrun{
check_bool("TRUE", name = "input")
} # }