How to merge two phrases into one in bigrams

I created a bigram from one speech and counted how many times each phrase was used. Following is the code and I attached its result.

bigram_counts_u <- bigram_counts %>% unite("word", word1:word2, sep = " ")
bigram_counts_u %>% top_n(15) %>%
ggplot(aes(fct_reorder(word, n), n)) +
geom_col() +
coord_flip() +
labs(x = NULL)

The problem is, there are "naval force" and "naval forces" which are the same. So I want to merge them together. I tried Str_replace_all function, but I got this error:

In stri_detect_regex(string, pattern, negate = negate, opts_regex = opts(pattern)) :
argument is not an atomic vector; coercing

Is there any way that I can merge "naval force" and "naval forces" into one?

Can you provide your str_replace_all call and an example dataset that reproduces the error? You can use dput() to copy the whole dataset, as described here.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.