pmatchIC {Ecfun}R Documentation

pmatch ignoring case

Description

pmatch with an additional ignoreCase argument, returning a name not an index like pmatch (and returning a name if supplied a number, unlike pmatch, which coerces the input to numeric).

Usage

pmatchIC(x, table, nomatch = NA_integer_, 
  duplicates.ok = FALSE, 
  ignoreCase=TRUE)

Arguments

x

the values to be matched. If is.numeric(x), pmatch2 returns table[x].

This is different from pmatch, which matches as.character(x).

Otherwise, if ignoreCase is TRUE, pmatchIC returns pmatch(tolower(x), tolower(table)).

table

the values to be matched against: converted to a character vector, per pmatch.

nomatch

the value to be returned at non-matching or multiply partially matching positions.

duplicates.ok

should elements be in table be used more than once? (See pmatch for an example.)

ignoreCase

logical: if TRUE and x is character, pmatchIC returns pmatch(tolower(x), tolower(table)).

Value

A character vector of matches.

Author(s)

Spencer Graves

See Also

pmatch

Examples

yr <- pmatchIC('Yr', c('y1', 'yr', 'y2'))

all.equal('yr', yr)


# integer
m2 <- pmatchIC(2, table=letters)

all.equal(m2, 'b')


[Package Ecfun version 0.3-2 Index]