View source: R/repcale_match.R
replace_match | R Documentation |
Function to replace a value that exactly matches a pattern with a replacement. Given a vector of equal length for pattern and replacement, the first value of pattern is interpreted as replacing the first value of replacement. See the argument descriptions for details.
replace_match(x, pattern, replacement, nomatch)
x |
Vector of values to be converted. |
pattern |
The value of the pattern to be converted or a vector containing it. If given in a vector of two or more lengths, it is determined that it should be replaced by a value equal to the position of each of the values given in the replacement argument. |
replacement |
The value of the replacement to be converted or a vector containing it. If given in a vector of two or more lengths, it is determined that it should be replaced by a value equal to the position of each of the values given in the pattern argument. |
nomatch |
Specifies the value to return if there is no matching pattern and replacement value. If no value is specified, the original x value is returned. |
values <- c("HOKKAIDOU", "hokkaidou", "TOUHOKU", "touhoku")
pattern <- c("hokkaidou", "touhoku")
replacement <- c("HOKKAIDOU", "TOUHOKU")
replace_match(values, pattern, replacement)
replace_match(values, pattern, replacement, nomatch = NA)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.