Substitute first occurence using sub
- sub
text <- "One cat two cats and another single cat"
print(text)
print(sub('cat', 'dog', text))
print(text)
[1] "One cat two cats and another single cat"
[1] "One dog two cats and another single cat"
[1] "One cat two cats and another single cat"