#Create vector of strings
vec <- c("Rose", "Thistle", "Leek", "Shamrock")
#View vector
vec[1] "Rose" "Thistle" "Leek" "Shamrock"
The function stringr::str_subset() returns the element of a vector that match a pattern/regular expression.
Prior to using the function create a vector of strings.
You can specify a string pattern to be used for detection.
The function is case-sensitive. “R” will detect “Rose” but not “shamrock”.
You can use various regular expressions.
You carry out an inverted search (i.e. it returns FALSE if it does match) with the option negate=TRUE.