powered by
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).
pmatch
ignoreCase
pmatchIC(x, table, nomatch = NA_integer_, duplicates.ok = FALSE, ignoreCase=TRUE)
A character vector of matches.
the values to be matched. If is.numeric(x), pmatch2 returns table[x].
is.numeric(x)
pmatch2
table[x]
This is different from pmatch, which matches as.character(x).
as.character(x)
Otherwise, if ignoreCase is TRUE, pmatchIC returns pmatch(tolower(x), tolower(table)).
TRUE
pmatchIC
pmatch(tolower(x), tolower(table))
the values to be matched against: converted to a character vector, per pmatch.
the value to be returned at non-matching or multiply partially matching positions.
should elements be in table be used more than once? (See pmatch for an example.)
logical: if TRUE and x is character, pmatchIC returns pmatch(tolower(x), tolower(table)).
x
Spencer Graves
yr <- pmatchIC('Yr', c('y1', 'yr', 'y2')) stopifnot( all.equal('yr', yr) ) # integer m2 <- pmatchIC(2, table=letters) stopifnot( all.equal(m2, 'b') )
Run the code above in your browser using DataLab