library(ggplot2) library(dplyr) library(completejourney) library(scales)
data <- transactions_sample %>% mutate(week_day = weekdays(transaction_timestamp)) %>% group_by(week_day) %>% summarise(total_sales = sum(sales_value, na.rm = TRUE)) %>% ungroup()
data\(week_day <- factor(data\)week_day, levels = c(“Monday”, “Tuesday”, “Wednesday”, “Thursday”, “Friday”, “Saturday”, “Sunday”))
ggplot(data, aes(x = week_day, y = total_sales, group = 1)) + geom_line(color = “blue”, size = 1) + geom_point(size = 3, color = “red”) + scale_y_continuous(labels = scales::dollar_format()) + labs( title = “Weekly Shopping Trends”, subtitle = “Spending peaks on weekends - particularly on Sundays”, x = “Day of the Week”, y = “Total Sales (\()", ) + theme_minimal() + annotate( "text", x = "Sunday", y = max(data\)total_sales) * 1.02, label =”Most Popular Shopping Day”, color = “black”, size = 4, hjust = .8)+ annotate( “text”, x = “Wednesday”, y = min(data$total_sales) * 0.98, label = “Least Popular Shopping Day”, color = “black”, size = 4, hjust = 0.2)