match_arg_exact: match.arg with exact matching

match.arg.exactR Documentation

match.arg with exact matching

Description

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"))

MARSS documentation built on May 29, 2024, 3:34 a.m.