1.Library requirement
library(esquisse)
library(dplyr)
library(ggplot2)
library(scales)
library(readxl)
bike_orderlines <- read_excel("bike_orderlines.xlsx")
3. Graph 1
ggplot(bikes_revenue) +
aes(x = year, fill = category_2, y = total_price) +
scale_fill_manual(values = c(`Cross Country Race` = "#2C3E50",
Cyclocross = "#E31A1C", `Elite Road` = "#18BC9C", `Endurance Road` = "#CCBE92", `Fat Bike` = "#A6CEE3",
`Over Mountain` = "#1F78B4", Sport = "#B2DF8A", Trail = "#FB9A99", Triathalon = "#FDBF6F")) +
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())

4. Graph 2
bikes_revenue$numyear <- as.numeric(as.character(bikes_revenue$year))
ggplot(bikes_revenue) +
aes(x = numyear, y = total_price, fill = category_2) +
geom_area(color = "black") +
scale_fill_brewer(palette = "Blues", 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())
