match_arg | R Documentation |
This function is essentially a clear version of base::match.arg()
which
produces a cleaner warning message and does not restrict the table
param
to character
vectors only.
match_arg(x, table)
x |
An argument |
table |
A table of choices |
Match arguments
A single value from x
matched on table
match_param()
x <- c("apple", "banana", "orange") match_arg("b", x) # Produces error try(match_arg("pear", x)) foo <- function(x, op = c(1, 2, 3)) { op <- match_arg(op) x / op } foo(10, 3) # Error try(foo(1, 0))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.