check_bool {erify} | R Documentation |
Check If Argument Is Single Logical
Description
Check if an argument is TRUE
or FALSE
, and if not,
generate an error message.
Usage
check_bool(
x,
name = NULL,
general = NULL,
specific = NULL,
supplement = NULL,
...
)
Arguments
x |
The argument to check, which can be any object. |
name |
A single character which gives the argument's name.
The name is used in the error message. By default, the name of the
argument passed to argument |
general |
Optional. A single character which is used to give a general statement of the error incurred. By default, this is generated automatically. |
specific |
Optional. A single character which gives a detailed description of the error. By default, this is generated automatically. |
supplement |
Optional. A (named) character vector which gives some
additional information about the error. The names are used to create
bullets, see |
... |
Optional. Additional arguments which can be retrieved with
|
Value
returns an invisible NULL
if the argument is valid, or
generates an error message.
See Also
"Examples" section in check_type()
for how to customize
error message and how to add and retrieve additional arguments.
vignette("erify")
for a gentle introduction to this package.
Examples
x <- TRUE
check_bool(x)
## Not run:
# `x` must have type logical
x <- 1
check_bool(x)
# `x` must have length 1
x <- c(TRUE, FALSE)
check_bool(x)
# `x` must not be `NA`
x <- NA
check_bool(x)
## End(Not run)