Checkmate Compatible Version of match.arg

Share:

Description

Matches arguments as match.arg and returns the value of the selected argument.

Usage

1
2
assert_match_arg(x, choices, several_ok = FALSE,
  .var.name = checkmate::vname(x), add = NULL)

Arguments

x

A character vecotr (of length one unless several.ok is TRUE or NULL.

choices

A character vector of candidate values

several_ok

logical specifying if arg should be allowed to have more than one element.

.var.name

character(1), name of the checked object to print in assertions. Defaults to the heuristic implemented in vname

add

AssertCollection, Colleciton to store assertion messages. See link[checkmate]{AssertCollection}.

...

Additional arguments to pass to either assertChoice or assertSubset. assertChoice is used when several_ok = FALSE, otherwise assertSubset is used.

See Also

match.arg, assertChoice, assertSubset