Busra Koc 25/11/2018

library(tidyverse)
## ── Attaching packages ───────────────────────────────────────────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.0.0     ✔ purrr   0.2.5
## ✔ tibble  1.4.2     ✔ dplyr   0.7.6
## ✔ tidyr   0.8.1     ✔ stringr 1.3.1
## ✔ readr   1.1.1     ✔ forcats 0.3.0
## ── Conflicts ──────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(dplyr)
library(ggplot2)
library(formattable)
library(lubridate)
## 
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
## 
##     date
odd_url <- ("https://github.com/MEF-BDA503/pj18-busraakoc/blob/master/car_data_aggregate.rds?raw=true")
odd_all_data <- readRDS(url(odd_url))
head(odd_all_data)
## # A tibble: 6 x 12
##   brand_name auto_dom auto_imp auto_total comm_dom comm_imp comm_total
##   <chr>         <dbl>    <dbl>      <dbl>    <dbl>    <dbl>      <dbl>
## 1 ALFA ROMEO        0       13         13        0        0          0
## 2 ASTON MAR…        0        2          2        0        0          0
## 3 AUDI              0      350        350        0        0          0
## 4 BENTLEY           0        0          0        0        0          0
## 5 BMW               0      158        158        0        0          0
## 6 CITROEN           0      134        134        0      197        197
## # ... with 5 more variables: total_dom <dbl>, total_imp <dbl>,
## #   total_total <dbl>, year <dbl>, month <dbl>
tail(odd_all_data)
## # A tibble: 6 x 12
##   brand_name auto_dom auto_imp auto_total comm_dom comm_imp comm_total
##   <chr>         <dbl>    <dbl>      <dbl>    <dbl>    <dbl>      <dbl>
## 1 SSANGYONG         0       19         19        0        3          3
## 2 TATA              0        0          0        0        9          9
## 3 TOYOTA         1298      149       1447        0       34         34
## 4 VOLKSWAGEN        0     2792       2792        0     1736       1736
## 5 VOLVO             0      187        187        0        0          0
## 6 TOPLAM:        7375    15983      23358     4815     4540       9355
## # ... with 5 more variables: total_dom <dbl>, total_imp <dbl>,
## #   total_total <dbl>, year <dbl>, month <dbl>
odd_all_data <- odd_all_data %>% filter(!grepl("ODD", brand_name)) %>% filter(!grepl("TOPLAM:", brand_name))
odd_all_data <- odd_all_data %>%
  mutate(brand_name=replace(brand_name,brand_name=="ASTON MARTÄ°N","ASTON MARTIN"))
sales_total <- odd_all_data %>%
  group_by(brand_name) %>%
  summarise(total_total = sum(total_total)) %>%
  arrange(desc(total_total))
head(sales_total)
## # A tibble: 6 x 2
##   brand_name total_total
##   <chr>            <dbl>
## 1 RENAULT         318500
## 2 FIAT            275900
## 3 FORD            271157
## 4 VOLKSWAGEN      262041
## 5 HYUNDAI         131666
## 6 DACIA           117978

Analaysis for Renault

renault_data <- odd_all_data %>% 
  select(brand_name,auto_total,auto_dom,comm_dom,total_imp,total_dom,total_total,year,month) %>% filter(brand_name == 'RENAULT') %>% arrange(desc(total_total))
str(renault_data)
## Classes 'tbl_df', 'tbl' and 'data.frame':    33 obs. of  9 variables:
##  $ brand_name : chr  "RENAULT" "RENAULT" "RENAULT" "RENAULT" ...
##  $ auto_total : num  18490 16240 11975 10831 11275 ...
##  $ auto_dom   : num  11492 11420 7692 6905 7292 ...
##  $ comm_dom   : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ total_imp  : num  9586 7634 6292 5855 5449 ...
##  $ total_dom  : num  11492 11420 7692 6905 7292 ...
##  $ total_total: num  21078 19054 13984 12760 12741 ...
##  $ year       : num  2016 2017 2017 2016 2016 ...
##  $ month      : num  12 12 11 11 5 6 4 6 7 10 ...

Graphs

ggplot(odd_all_data,aes(x=brand_name, y=mean(auto_total) ))