Replace all occurences of a string with gsub
gsub(pattern, replacement, x, ignore.case = FALSE, perl = FALSE, fixed = FALSE, useBytes = FALSE) x <- c("Hello", "world!") x <- gsub("o", 0, x) x [1] "Hell0" "w0rld!"