library(completejourney)
## Welcome to the completejourney package! Learn more about these data
## sets at http://bit.ly/completejourney.
library(ggplot2)
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
data1 <- transactions_sample %>%
inner_join(demographics, by = "household_id")
income_sales <- data1 %>%
group_by(income) %>%
summarise(total_sales = sum(sales_value, na.rm = TRUE))
ggplot(income_sales, aes(x = income, y = total_sales, fill = income)) +
geom_bar(stat = "identity") +
labs(title = "Total Sales by Household Income",
x = "Household Income",
y = "Total Sales Value") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))

data3 <- coupon_redemptions %>%
inner_join(demographics, by = "household_id")
coupon_age <- data3 %>%
group_by(age) %>%
summarise(total_redemptions = n())
ggplot(coupon_age, aes(x = age, y = total_redemptions, fill = age)) +
geom_bar(stat = "identity") +
labs(title = "Total Coupon Redemptions by Age Group",
x = "Age Group",
y = "Total Coupon Redemptions") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))

data4 <- transactions_sample %>%
inner_join(products, by = "product_id")
category_sales <- data4 %>%
group_by(product_category) %>%
summarise(total_sales = sum(sales_value, na.rm = TRUE)) %>%
arrange(desc(total_sales)) %>%
slice(1:10)
ggplot(category_sales, aes(x = reorder(product_category, -total_sales), y = total_sales)) +
geom_point(size = 4, color = "steelblue") +
labs(title = "Total Sales by Product Category (Top 10)",
x = "Product Category",
y = "Total Sales Value") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
