check_names | R Documentation |
This function checks whether required names are contained within an object. If the object does not contain any/all required names (the precise criteria is controlled by the user), the function returns a helpful error message.
check_names(
arg = deparse(substitute(input)),
input,
req,
extract_names = names,
type = any
)
arg |
A character string which defines the argument of the parent function. |
input |
An object for which the names need to be checked. |
req |
A character vector of required names. |
extract_names |
A function which is used to extract names from |
type |
A function which defines the failure criteria. For example, if |
If the input fails the check, the function returns a helpful error message. Otherwise, nothing is returned.
Edward Lavender
## Not run:
check_names(input = list(x = 1, y = 1),
req = c("a", "b", "c"),
extract_names = names,
type = all)
check_names(input = data.frame(b = 1, a = 1),
req = c("x", "y"),
extract_names = colnames,
type = any)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.