Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Substitute all occurences using gsub

  • gsub
text <- "One cat two cats and another single cat"
print(text)
print(gsub('cat', 'dog', text))
print(text)

[1] "One cat two cats and another single cat"
[1] "One dog two dogs and another single dog"
[1] "One cat two cats and another single cat"