0

I am new to R and I am working on a text mining project. I am facing difficulties with my Ngrams graph. My graph is not in descending order. I sorted the function count but it's still not working. I used this code:

nreviews %>% 
  unnest_tokens(word, ReqSummary, token = "ngrams", n = 2) %>% 
  separate(word, c("word1", "word2"), sep = " ") %>% 
  filter(!word1 %in% stop_words$word) %>%
  filter(!word2 %in% stop_words$word) %>% 
  unite(word,word1, word2, sep = " ") %>% 
  count(word, sort=TRUE) %>%
  slice(1:20) %>% 
  ggplot() + geom_bar(aes(word,n), stat = "identity", fill = "#de5833") +
  theme_minimal() +
  coord_flip() +
  labs(title = "Top 2-grams of Negative Reviews",
       subtitle = "using Tidytext in R",
       caption = "Data Source: After Sales Data")
Narin
  • 21
  • 3

0 Answers0