library(readr)
library(tidyverse)
library(scales)
library(stringr)
library(zoo)

Reading and manipulating the data:

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")

Total car sales per month

#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))

Market share by brand name

total_car_sales <-  car_sales %>% group_by(brand_name) %>% summarize(total_total=sum(total_total))
library(ggplot2)
library(treemapify)   
ggplot(total_car_sales, aes(area = total_total, fill = brand_name, label = brand_name)) +
  geom_treemap() +
  geom_treemap_text(fontface = "italic", colour = "white", place = "centre", grow = TRUE)+
  theme(legend.position = "bottom")