Using a vector (a column of a data frame) of strings, I'm trying to identify the string from which an excerpt of a string comes.
In the following example, excerpt_of_string
is an excerpt (specifically the first 119 characters) from the second element in vector_of_strings
:
excerpt_of_string <- "Considering utilizing eLearning days for snow make-up? Join us on 12/8 for Snow day, sNOw problem! Details https://t.co"
vector_of_strings <- c("Meow",
"Considering utilizing eLearning days for snow make-up? Join us on 12/8 for Snow day, sNOw problem! Details https://t.co/LfbPne3uuo #INeLearn",
"Bark")
I first tried to use grepl
, anticipating that the second element of vector_of_strings
would be TRUE
, but all the elements were false:
grepl(excerpt_of_string, vector_of_strings)
[1] FALSE FALSE FALSE
I also tried str_detect
from the stringr
package:
stringr::str_detect(vector_of_strings, excerpt_of_string)
[1] FALSE FALSE FALSE
Why are these methods not detecting the excerpt excerpt_of_string
in the second element of vector_of_strings
?