extending gsub by matching pattern and replacement from two vectors
VectorSub(pattern, replacement, string)
vector containing words to match
vector containing words to replace existing words.
string to replace from
modified string with replaced values
# NOT RUN {
pattern <- c("A","B","C")
replacement <- 1:3
string <- "A went to B went to C"
VectorSub(pattern,replacement,string)
# [1] "1 went to 2 went to 3"
# }
Run the code above in your browser using DataLab