View source: R/validate_argument.R
validate_argument | R Documentation |
This is a replacement for match.arg()
, however, the error
string should be more informative for users. The name of the affected argument
is shown, and possible typos as well as remaining valid options.
validate_argument(argument, options)
argument |
The bare name of the argument to be validated. |
options |
Valid options, usually a character vector. |
argument
if it is a valid option, else an error is thrown.
foo <- function(test = "small") {
validate_argument(test, c("small", "medium", "large"))
}
foo("small")
# errors:
# foo("masll")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.