library(readr)
library(tidyverse)
library(scales)
library(stringr)
library(zoo)
We will do some changes here to do data more readible such as merging date to “month and year”, removing some rows etc.
car_sales <- readRDS("C:\\Users\\oktay\\OneDrive\\Documents\\rodevi\\car_data_aggregate.rds")
car_sales <- car_sales %>% filter(brand_name !="TOPLAM:" & !str_detect(brand_name,"ODD"))
car_sales$brand_name <- str_replace(car_sales$brand_name,"ASTON MARTÄ°N","ASTON MARTIN")
#Total car sales per month .
monthly_sales <- car_sales %>% group_by(year,month) %>% summarise(total_auto=sum(auto_total))%>% arrange(year, month)%>%slice(1:12)
monthly_sales$Date <- zoo::as.yearmon(paste(monthly_sales$year,monthly_sales$month), "%Y %m")
monthly_sales$DateFormated <- format(monthly_sales$Date,"%Y-%m")
#ggplot lollipop chart
monthly_sales %>% ggplot( aes(x=DateFormated, y=total_auto)) +
geom_point(size=3) +
geom_segment(aes(x=DateFormated,
xend=DateFormated,
y=0,
yend=total_auto)) +
labs(title="Monthly Sales",
subtitle="Total sales per month",
caption="source: ODD reports") +
theme(axis.text.x = element_text(angle=65, vjust=0.6))