Skip to contents

The base R match.arg() uses pmatch() and does partial matching. This is a problem for many functions where "xtt1" is different than "xtt", say. This function implements exact matching.

Usage

match.arg.exact(arg, choices, several.ok = FALSE, exact = TRUE)

Arguments

arg

a character vector (of length one unless several.ok is TRUE).

choices

a character vector of candidate values

several.ok

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

exact

require exact matching

Examples

# this fails
# MARSS:::match.arg.exact(c("a"), c("aa", "bb"))
# this does not
match.arg(c("a"), c("aa", "bb"))
#> [1] "aa"