R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

text <- c(
  "I love the quality of this product. The price is reasonable, and delivery was fast.",
  "The product quality is excellent, but the shipping took too long.",
  "Great customer service! I would definitely recommend this product to my friends.",
  "The price is too expensive. However, the product looks beautiful.",
  "Fast delivery and excellent service. I am very satisfied with my purchase."
)

text

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidytext)

text_df <- tibble(line = 1:5, text = text)

text_df <- text_df %>%
  unnest_tokens(word, text)

data(stop_words)

text_df <- text_df %>%
  anti_join(stop_words, by = "word")
library(dplyr)
library(ggplot2)

text_df %>%
  count(word, sort = TRUE) %>%
  filter(n > 1) %>%
  mutate(word = reorder(word, n)) %>%
  ggplot(aes(n, word)) +
  geom_col() +
  labs(y = NULL)