imatch: Case-insensitive match and pmatch

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/imatch.R

Description

Case-insensitive match and pmatch functions, especially useful in parsing user inputs, e.g. from command line.

Usage

1

Arguments

x

String vector

table

A vector to be matched

...

Other parameters passed to match or pmatch

Details

imatch and ipmatch works similar as match and pmatch, except that they are case-insensitive.

matchv, imatchv and ipmatchv are shot-cuts to get the matched value (therefore the ā€˜vā€™) if the match succeeded, or NA if not. match(x, table) is equivalent to table[match(x, table)]. See examples.

Value

imatch and ipmatch returns matching indices, or NA (by default) if the match failed.

matchv, imatchv and ipmatchv returns the matching element in table, or NA if the match failed. Note that when cases are different in x and table, the one in table will be returned. This is especially useful for cases where user's input has different cases as the internal options.

Author(s)

Jitao David Zhang <jitao_david.zhang@roche.com>

See Also

match and pmatch

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
user.input <- c("hsv", "BvB")
user.input2 <- c("HS", "BV")
internal.options <- c("HSV", "FCB", "BVB", "FCN")

match(user.input, internal.options)
imatch(user.input, internal.options)
ipmatch(user.input, internal.options)
ipmatch(user.input2, internal.options)

matchv(user.input, internal.options)
matchv(tolower(user.input), tolower(internal.options))
imatchv(user.input, internal.options)
ipmatchv(user.input, internal.options)
ipmatchv(user.input2, internal.options)

ribiosUtils documentation built on March 13, 2020, 2:54 a.m.