char.expand
Expand a String with Respect to a Target Table
Description
Perform a partial match of a character value to the elements contained in
a character vector.
Usage
char.expand(input, target, nomatch = stop("no match"))
Arguments
input |
a character value containing the character string to expand.
|
target |
a vector containing the complete replacement character strings.
|
nomatch |
a character value or expression that is evaluated if input
does not match any string in target.
|
Value
returns the first instance of a partial match of the
element in the
input argument against the elements in the
target argument. The following outcomes are possible:
Match operation result | Return value |
Match exactly one string. | The matched string from target. |
Match more than one string. | An empty character vector character(0). |
No match. | Evaluates the nomatch argument, and then returns NA.
|
See Also
Examples
char.expand("l", c("low", "medium", "high"))
# [1] "low"
char.expand(input="A", target=c("B","C"), nomatch="")
# [1] NA