arg_match | R Documentation |
Useful when specifying allowed values for a function argument in a vector in the formals. See examples.
arg_match(arg)
arg |
The name of the argument in the parent function |
The value of arg after verifying, or an error
## Not run:
my_fun <- function(my_arg = c("a", "b")) {
my_arg <- arg_match(my_arg)
return(paste("The value is", my_arg))
}
my_fun("a")
my_fun("b")
my_fun("c")
my_fun()
my_fun(NULL)
my_fun(5)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.