Learn R Programming

MARSS (version 3.11.9)

match.arg.exact: 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

Run this code
# this fails
# MARSS:::match.arg.exact(c("a"), c("aa", "bb"))
# this does not
match.arg(c("a"), c("aa", "bb"))

Run the code above in your browser using DataLab