Mgsub | R Documentation |
Performs multiple substitions in (a) string(s).
Mgsub(pattern, replacement, x, ...)
pattern |
character string containing a regular expression (or character string for fixed = TRUE) to be matched in the given character vector. Coerced by as.character to a character string if possible. |
replacement |
a replacement for matched pattern as in |
x |
a character vector where matches are sought, or an object which can be coerced by as.character to a character vector. Long vectors are supported. |
... |
all dots are passed on to gsub. |
a character vector of the same length and with the same attributes as x (after possible coercion to character).
Andri Signorell <andri@signorell.net>
gsub
x <- c("ABC", "BCD", "CDE")
Mgsub(pattern=c("B", "C"), replacement=c("X","Y"), x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.