demographics %>%
inner_join(transactions_sample, by = "household_id") %>%
group_by(income) %>%
summarize(total = sum(sales_value)) %>%
ggplot(aes(x = income, y= total, fill = factor(ifelse(income == "50-74K","Highest", "Normal")))) +
geom_bar(stat="identity") +
scale_fill_manual(name="income", values=c("turquoise","grey50")) +
scale_y_continuous(name = "Total Amount of Money Spent", labels = scales::dollar) +
labs(
title = "Which Income Range Spends the Most Amount of Money",
subtitle= "This data has been collected over the past five years and sums the total amount
of money each income range spends at a grocery store",
x = "Income Range"
)

products %>%
inner_join(promotions_sample, by = "product_id") %>%
inner_join(coupons, by = "product_id") %>%
group_by(department, store_id) %>%
count(coupon_upc) %>%
ggplot(aes(x = n, y = department, color = store_id)) +
geom_point() +
facet_wrap(~ store_id) +
labs(
title = "Number of Coupons per Department",
subtitle = "Data about the number of coupons given out from two different stores has been collected",
x = "Number of Coupons Given Out",
y = "Store Department"
)

products %>%
filter(str_detect(product_category, "ICE CREAM")) %>%
distinct(product_id) %>%
inner_join(transactions_sample, by = "product_id") %>%
group_by(month = months(transaction_timestamp)) %>%
summarize(total = sum(sales_value)) %>%
ggplot(aes(x = month, y = total, group= 1)) +
geom_point (color = "turquoise") +
geom_line(color = "grey50") +
scale_x_discrete(limits = month.name) +
labs(
title = "Amount of Ice Cream Sold Each Month",
subtitle = "This data has been collected over the past five years",
x = "Months",
y = "Amount of Ice Cream Sold"
)
