Substitute first instance of a pattern in a text
text = "Apples and oranges are fruits"
sub("p", "b", text) # replace first instance of letter p with b
## [1] "Abples and oranges are fruits"
Substitute all instances of a pattern in a text
gsub("p", "b", text) # replace all instances of letter p with b
## [1] "Abbles and oranges are fruits"