I'm trying to find all the words with three consecutive double letters, e.g., bookkeeper.
Currently its giving me any word with double letters, rather than three consecutive sets.
This is where I am at:
Collins <- Collins %>%
filter(nchar(test) >= 5)
dbl_letter <- function(word, position){
substring(word, position, position) == substring(word, position+1, position+1)
}
for(word in Collins$test){
for(i in 1:nchar(word)){
if(dbl_letter(word,i) == TRUE & dbl_letter(word,i+2) == TRUE & dbl_letter(word,i+4) == TRUE){
print(word)
}
}
}