Let\'s say I have a long character string: pneumonoultramicroscopicsilicovolcanoconiosis. I\'d like to use stringr::str_replace_all
to replace certain letters w
I'm working on a package to deal with the type of problem. This is safer than the qdap::mgsub
function because it does not rely on placeholders. It fully supports regex as the matching and the replacement. You provide a named list where the names are the strings to match on and their value is the replacement.
devtools::install_github("bmewing/mgsub")
library(mgsub)
mgsub("developer",list("e" ="p", "p" = "e"))
#> [1] "dpvploepr"
qdap::mgsub(c("e","p"),c("p","e"),"developer")
#> [1] "dpvploppr"