powered by
This is equivalent to base::match.arg() with a few differences:
base::match.arg()
Partial matches trigger an error.
Error messages are a bit more informative and obey the tidyverse standards.
arg_match(arg, values = NULL)
A symbol referring to an argument accepting strings.
The possible values that arg can take. If NULL, the values are taken from the function definition of the caller frame.
arg
NULL
The string supplied to arg.
# NOT RUN { fn <- function(x = c("foo", "bar")) arg_match(x) fn("bar") # This would throw an informative error if run: # fn("b") # fn("baz") # }
Run the code above in your browser using DataLab