Is there a stringr
equivalent for grep
with value
set to TRUE
? (I would like to avoid the NA
s returned by the stringr
command below.)
library(stringr)
x <- c("a", "b", "a")
grep("a", x, value = TRUE) # returns "a" "a"
str_extract(x, "a") # returns "a" NA "a"