Introduction

This report analyzes five sample social media posts about customers’ product experiences. I used tidy text methods to split the posts into individual words, remove common stop words, and identify frequently mentioned topics.

1. Original Text Data

The original dataset contains one post per row. Each post includes multiple words, so it must be converted into a one-word-per-row format before counting individual words.

posts <- tibble(
  post_id = 1:5,
  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."
  )
)

kable(posts, caption = "Five sample social media posts")
Five sample social media posts
post_id text
1 I love the quality of this product. The price is reasonable, and delivery was fast.
2 The product quality is excellent, but the shipping took too long.
3 Great customer service! I would definitely recommend this product to my friends.
4 The price is too expensive. However, the product looks beautiful.
5 Fast delivery and excellent service. I am very satisfied with my purchase.

2. Tokenization

Tokenization separates text into individual words. The unnest_tokens() function creates one word per row, converts words to lowercase, and removes punctuation while keeping each word’s post ID.

tidy_posts <- posts %>%
  unnest_tokens(word, text)

kable(head(tidy_posts, 20),
      caption = "First 20 rows of tokenized text")
First 20 rows of tokenized text
post_id word
1 i
1 love
1 the
1 quality
1 of
1 this
1 product
1 the
1 price
1 is
1 reasonable
1 and
1 delivery
1 was
1 fast
2 the
2 product
2 quality
2 is
2 excellent

3. Remove Stop Words and Count Word Frequencies

Stop words are common words such as “the,” “and,” and “is.” Removing them helps highlight words that describe the customers’ experiences.

clean_posts <- tidy_posts %>%
  anti_join(stop_words, by = "word")

kable(clean_posts, caption = "Words remaining after stop-word removal")
Words remaining after stop-word removal
post_id word
1 love
1 quality
1 product
1 price
1 reasonable
1 delivery
1 fast
2 product
2 quality
2 excellent
2 shipping
3 customer
3 service
3 recommend
3 product
3 friends
4 price
4 expensive
4 product
4 beautiful
5 fast
5 delivery
5 excellent
5 service
5 satisfied
5 purchase
word_counts <- clean_posts %>%
  count(word, sort = TRUE)

kable(word_counts, caption = "Word frequencies")
Word frequencies
word n
product 4
delivery 2
excellent 2
fast 2
price 2
quality 2
service 2
beautiful 1
customer 1
expensive 1
friends 1
love 1
purchase 1
reasonable 1
recommend 1
satisfied 1
shipping 1

Word Frequency Chart

word_counts %>%
  filter(n >= 2) %>%
  ggplot(aes(x = reorder(word, n), y = n)) +
  geom_col(fill = "steelblue") +
  coord_flip() +
  scale_y_continuous(breaks = 0:max(word_counts$n)) +
  labs(
    title = "Words Mentioned at Least Twice",
    x = "Word",
    y = "Number of Mentions"
  ) +
  theme_minimal()

Findings

“Product” was the most frequent word, appearing four times, while “quality,” “price,” “delivery,” “fast,” “excellent,” and “service” each appeared twice. Reading the original posts alongside these counts suggests that quality, price, and delivery are key topics in this small sample, with praise for quality and service and concerns about high prices and slow shipping.

Marketing Application

A business could use these topics to guide a closer review of customer feedback about pricing and delivery. Because this sample includes only five posts, the findings cannot represent all customers’ opinions.

Reflection

One challenge was understanding how removing common words would help the analysis. Comparing the text before and after removing stop words helped me see how it made the main topics easier to identify.

Reference

Silge, J., & Robinson, D. Text Mining with R: A Tidy Approach. Chapter 1, Sections 1.1–1.3. https://www.tidytextmining.com/tidytext