string <- c("hey ho, let's go!")
chr.gsub(c("hey", "ho"), c("ho", "hey"), string)
string <- "they don't understand the value of what they seek."
chr.gsub(c("the", "they"), c("a", "we"), string)
string <- c("hey ho, let's go!")
chr.gsub(c("hey", "ho"), "yo", string, recycle = TRUE)
string <- "Dopazamine is not the same as dopachloride or dopastriamine, yet is still fake."
chr.gsub(c("[Dd]opa([^ ]*?mine)","fake"), c("Meta\\1","real"), string)
Run the code above in your browser using DataLab