This is an extensions to match.arg
with support for AssertCollection
.
The behavior is very similar to match.arg
, except that NULL
is not
a valid value for x
.
Usage
matchArg(x, choices, several.ok = FALSE, .var.name = vname(x), add = NULL)
Arguments
- x
[character]
User provided argument to match.- choices
[character()]
Candidates to matchx
with.- several.ok
[logical(1)]
IfTRUE
, multiple matches are allowed, cf.match.arg
.- .var.name
[
character(1)
]
Name of the checked object to print in error messages. Defaults to the heuristic implemented invname
.- add
[
AssertCollection
]
Collection to store assertions. SeeAssertCollection
.
Examples
matchArg("k", choices = c("kendall", "pearson"))
#> [1] "kendall"