Learn R Programming

r2rtf (version 1.0.2)

match_arg: Argument Verification Using Partial Matching

Description

Similar to match.arg(), match_arg matches arg against a table of candidate values as specified by choices.

Usage

match_arg(arg, choices, several.ok = FALSE)

Value

The matched elements of arg or in case of match failure a detailed error message

Arguments

arg

a character vector (of length one unless several.ok is TRUE) or NULL which means to take choices[1].

choices

a character vector of candidate values, often missing, see ‘Details’.

several.ok

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

Specification

The contents of this section are shown in PDF user manual only.

Details

This function resolves errors from match.arg() with '' as arg input.

Examples

Run this code
if (FALSE) {
match_arg(arg = c(2, 1), choices = c(4, 3, 1, 2), several.ok = TRUE)
match_arg(arg = c("c", "b"), choices = c("a", "b", "c", "d"), several.ok = TRUE)
}

Run the code above in your browser using DataLab