library(tidyverse)
library(readxl)
library(scales)
library(lubridate)

load("C:/Users/riaku/Downloads/webshop.RData") 

library(readxl)
income_statement <- read_excel("C:/Users/riaku/Downloads/Income_statement.xlsx")

library(readxl)
promotions <- read_excel("C:/Users/riaku/Downloads/promotions.xlsx")

library(readxl)
prices <- read_excel("C:/Users/riaku/Downloads/Prices.xlsx")


# how the customer purchases change over the years

yearly_behavior <- purchases %>%
  group_by(year) %>%
  summarise(
    n_transactions = n(),
    n_customers = n_distinct(VisitID),
    avg_order = mean(Payment),
    avg_discount = mean(Discount) * 100)
##graphing this data 


p2 <- ggplot(yearly_behavior, aes(x = year, y = n_transactions)) +
  geom_line(color = "brown", size= 1) +
  geom_point(color = "brown", size = 3) +
  geom_text(aes(label = comma(n_transactions)), vjust = -1) +
  scale_y_continuous(labels = comma) +
  labs(title = "Number of Transactions per Year",
       subtitle = "Is Rita losing her customers?",
       x = "Year",
       y = "Number of Transactions") +
  theme_minimal()

p2

p1