Searching and Replacing Text
grepl tests, sub and gsub replace, strsplit splits and regmatches extracts.
Example
s <- c("apple", "banana", "cherry")
print(grepl("an", s))
print(sub("a", "A", s))
print(gsub("a", "A", s))
print(strsplit("a,b,c", ",")[[1]])
print(toupper(substr(s, 1, 1)))Exercise
Replace all.
("a", "b", x)Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.