1
I have the following structure:
library(stringr)
filtro_palavras <- structure(list(palavras = c("cultivo", "produtos", "atacadista",
"papel", "madeira", "água", "agrícola", "vestuário", "calçados",
"fumo", "agricultura", "bebidas", "agropecuária", "florestas",
"abate")), row.names = c(NA, 15L), class = "data.frame")
I would like to replace the words that start with "agr" (in this case: agricultural, cagropecuária) by agr.
For that, I’m trying the following:
filtro_palavras$palavras <- str_replace_all(filtro_palavras$palavras, "^agr", "agr")
But no change happens.
Interesting! Can explain better what it would be
fronteira de palavra
and the\\b
? Thank you!– RxT
@Rxt There is an explanation about the
\b
here– hkotsubo
@hkotsubo Or here, in the paragraph before "A regular Expression may be Followed by one of several Repetition quantifiers".
– Rui Barradas