Skip to content
RDocumentation: str_subset
Note that this notebook was automatically generated from an RDocumentation page. It depends on the package and the example code whether this code will run without errors. You may need to edit the code to make things work.
if(!require('stringr')) {
install.packages('stringr')
library('stringr')
}
fruit <- c("apple", "banana", "pear", "pineapple")
str_subset(fruit, "a")
str_subset(fruit, "^a")
str_subset(fruit, "a$")
str_subset(fruit, "b")
str_subset(fruit, "[aeiou]")
# Elements that don't match
str_subset(fruit, "^p", negate = TRUE)
# Missings never match
str_subset(c("a", NA, "b"), ".")