
210 | Capítulo 11: Strings com stringr
Normalmente, no entanto, suas strings serão uma coluna de um data frame e você vai
querer usar filter:
word = words,
i = seq_along( word )
%>%
filter( str_detect( words, "x$"
2
i
#> <chr> <int>
#> 1 box 108
#> 2 sex 747
#> 3 six 772
#> 4 tax 841
Uma variação de str_ d ete ct() é str_co u nt(): em vez de um simples sim ou não, ela
lhe diz quantas combinações existem em uma string:
x <- c( "apple", "banana", "pear" )
str_coun
t( x, "a" )
1
# On average, how many vowels per word?
mean
( str_count( words, "[aeiou]" ))
É natural usar str_ ...