Mgsub: Multiple Gsub

View source: R/StatsAndCIs.r

MgsubR Documentation

Multiple Gsub

Description

Performs multiple substitions in (a) string(s).

Usage

Mgsub(pattern, replacement, x, ...)

Arguments

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 sub and gsub. See there for more information.

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.

Value

a character vector of the same length and with the same attributes as x (after possible coercion to character).

Author(s)

Andri Signorell <andri@signorell.net>

See Also

gsub

Examples

x <- c("ABC", "BCD", "CDE")
Mgsub(pattern=c("B", "C"), replacement=c("X","Y"), x)

AndriSignorell/DescTools documentation built on April 13, 2024, 6:33 a.m.