library(completejourney)
library(tidyverse)
transactions <- transactions_sample
promotions <- promotions_sample
demographics %>%
inner_join(transactions, by = "household_id") %>%
inner_join(coupon_redemptions, by = "household_id") %>%
group_by(income, day = lubridate::wday(redemption_date, label = TRUE)) %>%
summarize(Total_redemptions = n()) %>%
ggplot(aes(x = Total_redemptions, y = income, color = income)) +
geom_point() +
facet_wrap(~ day, nrow = 2) +
scale_x_continuous( name = "Total Redemptions", labels = scales::label_number_si(""))+
labs(title = "Coupon Redemptions by Income on Specific Day of Week",
x = "Total Redemptions",
y = "Income Class",
color = "Income Class")

transactions %>%
inner_join(products, by = "product_id") %>%
group_by(department, month = lubridate::month(transaction_timestamp, label = TRUE)) %>%
summarize(sales = sum(sales_value)) %>%
ggplot(aes(x = sales, y = department, fill = department))+
geom_col()+
theme(axis.text.y = element_text(size=4))+
theme(axis.text.x = element_text(size = 4))+
scale_x_continuous( name = "Sales", labels = scales::label_number_si(""))+
facet_wrap(~month, nrow = 2)+
labs(title = "Sales per Department by Month",
subtitle = "Department sales collected",
x = "Sales",
y = "Departments",
color = "Departments")

promotions %>%
inner_join(transactions, by = "product_id") %>%
group_by(mailer_location,product_id) %>%
summarize(Total_sales = sum(sales_value)) %>%
ggplot(aes(fct_reorder(mailer_location,Total_sales), y = Total_sales, fill = mailer_location)) +
geom_col()+
scale_y_continuous(name = "Total Sales", labels = scales::label_dollar())+
scale_x_discrete(name = "Locations")+
labs(title = "Sales by Mailer Location",
subtitle = "Mailer Locations based on the promotions of products",
x = "Mailer Location",
y = "Total Sales",
color = "Locations")
