I have made a function to search words which have two vowels together. The function give me the vowels together (for example: ee, ou), but I need the complete word (tree, four).
lt <- c("tree", "four", "hello", "play")
vowel <- function(x) {
a<- regexpr(pattern = "[aeiou]{2}", x)
regmatches(x, a)
}
vowel(lt)
# [1] "ee" "ou"
Thank you in advance
>Solution :
We can simply use grepl which in my opinion is more user friendly.
vowel <- function(x)
{
a<- grepl("[aeiou]{2}", x)
x[a]
}
vowel(lt)
[1] "tree" "four"