R/mgsub.R

Defines functions mgsub

Documented in mgsub

mgsub <- function(pattern, 
                  replacement, 
                  x, 
                  ...) {
  if (length(pattern) != length(replacement)) {
    stop("pattern and replacement do not have the same length.")
  }
  result <- x
  for (i in 1:length(pattern)) {
    result <- gsub(pattern[i], 
                   replacement[i], 
                   result, 
                   ...)
  }
  result
}

Try the gexp package in your browser

Any scripts or data that you put into this service are public.

gexp documentation built on July 9, 2023, 5:42 p.m.