Plot 1
transactions %>%
inner_join(demographics, by = 'household_id') %>%
mutate(month = month(transaction_timestamp, label = TRUE)) %>%
filter(month %in% c("Jun", "Jul", "Aug")) %>%
group_by(month, income) %>%
summarize(total_sales = sum(sales_value, na.rm = TRUE), .groups = 'drop') %>%
ggplot(aes(x = income, y = total_sales, color = month)) +
geom_point(size = 2, shape = 18) +
facet_wrap(~month, nrow = 3) +
labs(title = "Total Sales by Income During the Summer Months",
x = "Income",
y = "Total Sales")

Plot 2
products %>%
inner_join(transactions, by = 'product_id') %>%
inner_join(demographics, by = 'household_id') %>%
mutate(marital_status = replace_na(marital_status, "Unknown")) %>%
filter(product_category == "VITAMINS") %>%
group_by(marital_status) %>%
ggplot(aes(x = marital_status)) +
geom_bar() +
labs(title = "Vitamins Purchased Based on Marital Status",
x = "Marital Status",
y = "Number of Vitamins")

Plot 3
coupon_redemptions %>%
inner_join(demographics, by = "household_id") %>%
inner_join(transactions, by = "household_id", relationship = "many-to-many") %>%
group_by(household_size) %>%
summarize(total_redemption_value = sum(coupon_disc, na.rm = TRUE)) %>%
ggplot(aes(x = household_size, y = total_redemption_value, color = household_size)) +
geom_point(size = 3) +
labs(title = "Coupon Redemption Value By Household Size",
x = "Household Size",
y = "Total Value of Coupon Redemptions") +
scale_y_continuous(label = scales::dollar, breaks = seq(from = 0, to = 2000, by = 100))
