String Manipulation with stringr in R
Charlotte Wickham
Assistant Professor at Oregon State University
str_replace("Tom & Jerry",
pattern = "&",
replacement = "and")
"Tom and Jerry"
str_replace("Alvin & Simon & Theodore",
pattern = "&",
replacement = "and")
"Alvin and Simon & Theodore"
str_replace_all("Alvin & Simon & Theodore",
pattern = "&",
replacement = "and")
"Alvin and Simon and Theodore"
chars <- c("Tom & Jerry", "Alvin & Simon & Theodore")
str_replace_all(chars, pattern = "&", replacement = "and")
"Tom and Jerry" "Alvin and Simon and Theodore"
String Manipulation with stringr in R