this is my code:
searchvector <- c("good", "wonderful", "bad", "great", "wonder")
> grepl("wonder", searchvector)
[1] FALSE TRUE FALSE FALSE TRUE
> grepl(paste0("\\b", "wonder", "\\b"), searchvector)
[1] FALSE FALSE FALSE FALSE TRUE
> grepl(paste0("\\baudible\\b|\\b|\\bthalia\\b"), searchvector)
[1] TRUE TRUE TRUE TRUE TRUE
I have a large vector with text, where i want to seperate each word to calculate sentiment scores. I only want to match only exact strings, which i managed to do with \\b
.
However, some texts matches the whole searchvector as you can see. I was not able to figure out why that is the case. Can anyone explain me what goes wrong here?