match_arg {mark} | R Documentation |
Match arguments
Description
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.
Usage
match_arg(x, table)
Arguments
x |
An argument |
table |
A table of choices |
Details
Match arguments
Value
A single value from x
matched on table
See Also
Examples
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))
[Package mark version 0.8.0 Index]