Introduction

We were assigned with a task to take this ‘completejourney’ data and create a business problem and solution for Regork.

Business Problem

We identified glaring differences between beer, liquor, and wine sales from different demographics. We also noticed similar trends between total sales by month for the three alcoholic products. The problem we are trying to solve is how beer affects other alcoholic beverages and what products are bought at similar times to beer.

Why Is This Important?

Alcohol is a very important product to grocery stores, and we are creating an analysis to help Regork be able to improve where they can position products that compliment the alcoholic beverages. This analysis can also push Regork to position products next to other products or run promotions based on demographics and what day it is.

Packages Required

library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.2.3
## Warning: package 'ggplot2' was built under R version 4.2.3
## Warning: package 'tibble' was built under R version 4.2.3
## Warning: package 'tidyr' was built under R version 4.2.3
## Warning: package 'readr' was built under R version 4.2.3
## Warning: package 'dplyr' was built under R version 4.2.3
## Warning: package 'forcats' was built under R version 4.2.3
## Warning: package 'lubridate' was built under R version 4.2.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.2     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.2     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.1     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the ]8;;http://conflicted.r-lib.org/conflicted package]8;; to force all conflicts to become errors
library(completejourney)
## Warning: package 'completejourney' was built under R version 4.2.3
## Welcome to the completejourney package! Learn more about these data
## sets at http://bit.ly/completejourney.
transactions <- get_transactions()
products <- products
demographics <- demographics

Analysis

Beer

transactions %>%
  inner_join(products)  %>%
  inner_join(demographics, by = "household_id") %>%
  mutate(day_of_week = wday(transaction_timestamp, label = TRUE), 
         day_of_week = fct_collapse(day_of_week, Weekdays = c("Mon", "Tue", "Wed", "Thu")),
         day_of_week = fct_collapse(day_of_week, Weekend = c("Fri", "Sat", "Sun")),
         day_of_week = fct_relevel(day_of_week, "Weekdays", "Weekend"))%>%
  mutate(marital_status = fct_recode(marital_status)) %>%
  filter(str_detect(product_category, regex("BEER", ignore_case = TRUE))) %>% 
  ggplot(aes(marital_status)) +
  geom_bar(color= "Yellow") +
  facet_wrap(~day_of_week) +
  ggtitle("Beer Products Bought by Marital Status",
          subtitle = "By Weekday and Weekend") +
  scale_x_discrete(labels = c("Married", "Unmarried", "Unknown"),
                   labs(title= "Income"))
## Joining with `by = join_by(product_id)`

transactions %>%
  inner_join(products) %>%
  inner_join(demographics, by = "household_id")  %>%
  filter(str_detect(product_category, regex("beer", ignore_case = TRUE))) %>%
  ggplot(aes(x = sales_value , y = income)) +
  geom_boxplot(color = "Yellow") +
  ggtitle("Sales Value of Beer by Income Range") +
  scale_x_continuous(labs(title = "Sales Value"))
## Joining with `by = join_by(product_id)`

transactions %>%
  inner_join(products, by = "product_id") %>%
  inner_join(demographics, by = "household_id") %>%
  filter(str_detect(product_category, regex("beer", ignore_case = TRUE))) %>%
  mutate(month = month(transaction_timestamp, label = TRUE)) %>%
  group_by(month) %>%
  summarise(total_sales = sum(sales_value)) %>%
  ggplot(aes(y = total_sales, x  = month)) +
  geom_col(color= "Yellow") +
  ggtitle("Beer Sales by Month") +
  scale_y_continuous(labs(title = "Total sales"), labels = scales:: dollar) +
  scale_x_discrete(labs(title = "Month"))

As expected, the weekend has more beer sales, but the unmarried group hardly changes throughout the weekend and weekday while married people have a large increase during the weekend.

Beer doesn’t have a noticeable trend from sales value and income of a person like other products. We assume this is because beer is relatively inexpensive and similarly priced throughout the quality of drinks.

The biggest spikes of beer sales are during the Summer months, and then in December. We will be looking at products that have a similar trend to understand what products are likely bought together when a person is shopping.

Wine

transactions %>%
  inner_join(products)  %>%
  inner_join(demographics, by = "household_id") %>%
  mutate(day_of_week = wday(transaction_timestamp, label = TRUE), 
         day_of_week = fct_collapse(day_of_week, Weekdays = c("Mon", "Tue", "Wed", "Thu")),
         day_of_week = fct_collapse(day_of_week, Weekend = c("Fri", "Sat", "Sun")),
         day_of_week = fct_relevel(day_of_week, "Weekdays", "Weekend"))%>%
  mutate(marital_status = fct_recode(marital_status)) %>%
  filter(str_detect(product_category, regex("WINE", ignore_case = TRUE))) %>% 
  ggplot(aes(marital_status)) +
  geom_bar(color= "RED") +
  facet_wrap(~day_of_week) +
  ggtitle("Wine Products Bought by Marital Status",
          subtitle = "By Weekday and Weekend") +
  scale_x_discrete(labels = c("Married", "Unmarried", "Unknown"),
                   labs(title= "Income"))
## Joining with `by = join_by(product_id)`

transactions %>%
  inner_join(products)  %>%
  inner_join(demographics, by = "household_id") %>%
  filter(department == 'GROCERY') %>%
  filter(str_detect(product_category, regex("WINE", ignore_case = TRUE))) %>%
  ggplot(aes(x=product_category, y=quantity)) +
  geom_point(color= "RED") +
  ggtitle("Quantity of Wine Bought by Product") +
  scale_y_continuous(labs(title = "Quantity Bought")) +
  scale_x_discrete(labs(title = "Product"))
## Joining with `by = join_by(product_id)`

transactions %>%
  inner_join(products) %>%
  inner_join(demographics, by = "household_id")  %>%
  filter(str_detect(product_category, regex("Wine", ignore_case = TRUE))) %>%
  ggplot(aes(x = sales_value , y = income)) +
  geom_boxplot(color="RED") +
  ggtitle("Sales Value of Wine by Income Range") +
  scale_x_continuous(labs(title = "Sales Value"))
## Joining with `by = join_by(product_id)`

## Wine Monthly Data

transactions %>%
  inner_join(products, by = "product_id") %>%
  inner_join(demographics, by = "household_id") %>%
  filter(str_detect(product_category, regex("wine", ignore_case = TRUE))) %>%
  mutate(month = month(transaction_timestamp, label = TRUE)) %>%
  group_by(month) %>%
  summarise(total_sales = sum(sales_value)) %>%
  ggplot(aes(y = total_sales, x  = month)) +
  geom_col(color = "RED") +
  ggtitle("Wine Sales by Month") +
  scale_y_continuous(labs(title = "Total sales"),labels = scales:: dollar) +
  scale_x_discrete(labs(title = "Month"))

Customers have a different outlook on wine than they did on beer as you can see. The slight difference from weekdays to weekends in now with the married people with a slight increase. There is also, a large decrease in wine sales from unmarried people on the weekends. This could be because they are drinking more beer on the weekends rather than wine.

It seems customers are also more likely to buy a larger quantity of domestic wine rather than imported or miscellaneous wines.

Differing from beer, wine does increase price when increasing quality, which can be proven by the distribution of income range and sales value. There is a slightly increasing trend from the average sales value based on income range of a person.

Wine has almost an opposite trend of beer other than the month of December. The summer months are actually the lowest in total sales while the beginning months are the highest in sales.

Liquor

transactions %>%
  inner_join(products)  %>%
  inner_join(demographics, by = "household_id") %>%
  mutate(day_of_week = wday(transaction_timestamp, label = TRUE), 
         day_of_week = fct_collapse(day_of_week, Weekdays = c("Mon", "Tue", "Wed", "Thu")),
         day_of_week = fct_collapse(day_of_week, Weekend = c("Fri", "Sat", "Sun")),
         day_of_week = fct_relevel(day_of_week, "Weekdays", "Weekend"))%>%
  mutate(marital_status = fct_recode(marital_status)) %>%
  filter(str_detect(product_category, regex("LIQUOR", ignore_case = TRUE))) %>% 
  ggplot(aes(marital_status)) +
  geom_bar(color= "BLUE") +
  facet_wrap(~day_of_week) +
  ggtitle("Liquor Products Bought by Marital Status",
          subtitle = "By Weekday and Weekend") +
  scale_x_discrete(labels = c("Married", "Unmarried", "Unknown"),
                   labs(title= "Income"))
## Joining with `by = join_by(product_id)`

transactions %>%
  inner_join(products) %>%
  inner_join(demographics, by = "household_id")  %>%
  filter(str_detect(product_category, regex("Liquor", ignore_case = TRUE))) %>%
  ggplot(aes(x = sales_value , y = income)) +
  geom_boxplot(color="BLUE") +
  ggtitle("Sales Value of Liquor by Income Range") +
  scale_x_continuous(labs(title = "Sales Value"))
## Joining with `by = join_by(product_id)`

## Liquor Monthly Data

transactions %>%
  inner_join(products, by = "product_id") %>%
  inner_join(demographics, by = "household_id") %>%
  filter(str_detect(product_category, regex("liquor", ignore_case = TRUE))) %>%
  mutate(month = month(transaction_timestamp, label = TRUE)) %>%
  group_by(month) %>%
  summarise(total_sales = sum(sales_value)) %>%
  ggplot(aes(y = total_sales, x  = month)) +
  geom_col(color="BLUE") +
  ggtitle("Liquor Sales by Month") +
  scale_y_continuous(labs(title = "Total sales"),labels = scales:: dollar) +
  scale_x_discrete(labs(title = "Month"))

Liquor doesn’t have a change between married and unmarried customers such as the wine and beer customers did as there is just a scaled increase from the weekdays to the weekend.

Liquor actually has an increase in average sales value in the middle income ranges.

Liquor also has the most sales in December but are more like beer where the most sales occur in summer months.

Products Bought With

Based on the comparisons of these products we found two items that have similar trends to beer and could be purchased together going to events or family gatherings.

library(tidyverse)
library(completejourney)

## Chips Monthly Data

transactions %>%
  inner_join(products, by = "product_id") %>%
  inner_join(demographics, by = "household_id") %>%
  filter(str_detect(product_category, regex("chips", ignore_case = TRUE))) %>%
  mutate(month = month(transaction_timestamp, label = TRUE)) %>%
  group_by(month) %>%
  summarise(total_sales = sum(sales_value)) %>%
  ggplot(aes(y = total_sales, x  = month)) +
  geom_col(color= "ORANGE") +
  ggtitle("Chip Sales by Month") +
  scale_y_continuous(labs(title = "Total sales"),labels = scales:: dollar) +
  scale_x_discrete(labs(title = "Month"))

## Lime Monthly Data

transactions %>%
  inner_join(products, by = "product_id") %>%
  inner_join(demographics, by = "household_id") %>%
  filter(str_detect(product_type, regex("lime", ignore_case = TRUE))) %>%
  mutate(month = month(transaction_timestamp, label = TRUE)) %>%
  group_by(month) %>%
  summarise(total_sales = sum(sales_value)) %>%
  ggplot(aes(y = total_sales, x  = month)) +
  geom_col(color = "GREEN") +
  ggtitle("Lime Sales by Month") +
  scale_y_continuous(labs(title = "Total sales"),labels = scales:: dollar) +
  scale_x_discrete(labs(title = "Month"))

Summary

As you can see with this data, all of these products spike in the summer months and then in December. We believe this is because there are more events and social gatherings in the Summer where customers will be bringing alcohol, chips, and limes to. In December, there are many holidays and children are out of school causing for more events as well. We believe that chips and lime were ideal complimentary products because chips are a very common snack to be eaten at places where there is alcohol. Limes, go with many kinds of beers, liquors, and wines as well creating a relationship between them.

Our Opinion

Regork should understand what alcoholic beverages will be bought by the customers based on their marital status, day of the week, and income ranges are. Looking at what demographics buy which products, such as beer and wine being bought more during the weekdays than liquor, Regork can set certain promotions with these products during weekdays. We also believe that Regork should position their chip isle next to the beer isle and should put limes on an end cap of this isle.