View source: R/check-contents.R
check_contents | R Documentation |
Check if each item of an argument is from some given choices or satisfies some requirement, and if not, generate an error message.
check_contents(
x,
valid,
name = NULL,
general = NULL,
specific = NULL,
supplement = NULL,
as_double = TRUE,
...
)
x |
The argument to check, which can be any object. |
valid |
can be
|
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 |
as_double |
Optional. |
... |
Optional. Additional arguments which can be retrieved with
|
returns an invisible NULL
if the argument is valid, or
generates an error message.
"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.
## Not run:
x <- c(1, 2, 3)
check_contents(x, c(4, 5))
general = "Each item of `x` must be `NA`."
# `valid` can be a function or R code
check_contents(x, is.na, general = general)
check_contents(x, "is.na(x_i)", general = general)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.