Yes there are chartr:
chartr("áé" ,"ae","ána belén")
# [1] "ana belen"
Change . Since now you have asked for a more general function that can handle whole words, here is what I will do:
rgsub <- function(pattern, replacement, x) {
ARGS <- Map(c, pattern = pattern, replacement = replacement)
FUN <- function(x, y) gsub(y[['pattern']], y[['replacement']], x)
Reduce(FUN, ARGS, x)
}
To show that it gives the same results as qdap, but a little faster:
i <- c("cat", "dog", "mouse")
j <- c("lion", "bulldog", "elephant")
k <- c("cat", "dog", "dog", "mouse", "ant", "mouse")
identical(mgsub(i, j, k), rgsub(i, j, k))
library(microbenchmark)
microbenchmark(mgsub(i, j, k), rgsub(i, j, k))
qdap, , , .