I have a list of words. I want to count the words that have a certain letter repeatedly appears. I don't mind how many times the letter repeated appears, as long as it appears at least twice. I don't mind if the repetition is adjacent or not. I want to include both "ppa" and "pepa" for example.
fruit <- c("apple", "banana", "pear", "pineapple", "papaya")
Say this is my list. My target letter is "p". I want to count words that have at least two "p". So I want to count "apple", "pineapple", and "papaya". The number I want to obtain is 3.
I've tried
str_detect(fruit, "p[abcdefghijklmmoqrstuvwxyz]p")
But this does not count "apple" and "pineapple". Is there a way to have all three words included?