I have a text vector with five elements named text2. It is a sample of an actual dataset with over 1,800 rows and multiple columns.
I have reviewed other code solutions in stackoverflow and could not find a match.
Input
text2 <- c("Ian Desmond hits an inside-the-park home run (8) on a line drive down the right-field line. Brendan Rodgers scores. Tony Wolters scores." , "Ian Desmond lines out sharply to center fielder Jason Heyward.", "Ian Desmond hits a grand slam (9) to right center field. Charlie Blackmon scores. Trevor Story scores. David Dahl scores.", "Ian Desmond homers (12) on a fly ball to center field. Daniel Murphy scores.", "Wild pitch by pitcher Jake Faria. Sam Hilliard scores.")
Output I want to know which elements in text2 contain both "Wild pitch" and "scores." I would like both the count and the element numbers. For example, in text2 only one element (the last one) is a match. Thus, the output would contain both the count (1) and the element number (5).
Code tried
str_detect(text2, ("Wild pitch|scores"))