check_input {BayesTools} | R Documentation |
Check input
Description
A set of convenience functions for checking objects/arguments to a function passed by a user.
Usage
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 = ""
)
Arguments
x |
object to be checked |
name |
name of the object that will be print in the error message. |
check_length |
length of the object to be checked. Defaults to
|
allow_NULL |
whether the object can be |
allow_NA |
whether the object can contain |
call |
string to be placed as a prefix to the error call. |
allow_values |
names of values allowed in a character vector.
Defaults to |
lower |
lower bound of allowed values.
Defaults to |
upper |
upper bound of allowed values.
Defaults to |
allow_bound |
whether the values at the boundary are allowed.
Defaults to |
check_names |
names of entries allowed in a list. Defaults to
|
all_objects |
whether all entries in |
allow_other |
whether additional entries then the specified in
|
Value
returns NULL
, called for the input check.
Examples
# check whether the object is logical
check_bool(TRUE, name = "input")
# will throw an error on any other type
## Not run:
check_bool("TRUE", name = "input")
## End(Not run)