match_param {mark} | R Documentation |
Match params
Description
Much like base::match.arg()
with a few key differences:
Will not perform partial matching
Will not return error messages with ugly quotation marks
Usage
match_param(param, choices, null = TRUE)
Arguments
param |
The parameter |
choices |
The available choices; named lists will return the name (a character) for when matched to the value within the list element |
null |
If |
Details
Param matching for an argument
Value
A single value from param
matched on choices
See Also
Examples
fruits <- function(x = c("apple", "banana", "orange")) {
match_param(x)
}
fruits() # apple
try(fruits("b")) # must be exact fruits("banana")
# can have multiple responses
how_much <- function(x = list(too_few = 0:2, ok = 3:5, too_many = 6:10)) {
match_param(x)
}
how_much(1)
how_much(3)
how_much(9)
[Package mark version 0.7.0 Index]