fruit <- c("apple", "banana", "pear", "pinapple")
str_subset(fruit, "a")
str_subset(fruit, "^a")
str_subset(fruit, "a$")
str_subset(fruit, "b")
str_subset(fruit, "[aeiou]")
# Missings are silently dropped
str_subset(c("a", NA, "b"), ".")
Run the code above in your browser using DataLab