library(esquisse)
library(dplyr)
library(ggplot2)
library(scales)
library(readxl)
bike_orderlines <- read_excel("bike_orderlines.xlsx")
bike_orderlines$year <- format(as.Date(bike_orderlines$order_date, format="%Y/%m/%d"),"%Y")
bikes <- bike_orderlines %>%
select(total_price,category_2, year) %>%
group_by(year,category_2)%>%
summarise(total_price) %>%
group_by(year, category_2) %>% summarise_at(vars(total_price),funs(sum(.,na.rm=TRUE)))
ggplot(bikes) +
aes(x = year, fill = category_2, y = total_price) +
scale_fill_brewer(palette = "Set7")+
theme_bw() +
theme(legend.position = "bottom") +
labs(
y = "Revenue",
title = "Revenue by year",
subtitle = "Upward trend"
) +
facet_wrap(vars(category_2), scales = "free_y")+
geom_col() +
geom_smooth(aes(group=1),method="lm", se =FALSE)+
scale_y_continuous(labels=scales::dollar_format())

bikes$numyear <- as.numeric(as.character(bikes$year))
ggplot(bikes) +
aes(x = numyear, y = total_price, fill = category_2) +
geom_area(color = "black") +
scale_fill_brewer(palette = "white", direction = 1) +
labs(
y = "Revenue",
x = "Year",
title = "Sale Over Year by Category 2",
subtitle = "Sale Trending Up",
fill = "2nd category"
) +
theme_bw() +
theme(
plot.title = element_text(face = "bold"),
plot.subtitle = element_text(face = "bold"),
axis.title.y = element_text(face = "bold")
) + scale_y_continuous(labels=scales::dollar_format())
