Install necessary packages first.

install.packages("tidyverse", repos = "https://cran.r-project.org")
library(tidyverse)
install.packages("readxl")
devtools::install_github("tidyverse/dplyr")
install.packages("magrittr")
library(magrittr)

Coding

tmp <-tempfile(fileext=".xlsx")
#download file from rep1ository to the temporary file
download.file("https://github.com/MEF-BDA503/pj18-gokceezeroglu/blob/master/odd_retail_sales_2016_12.xlsx?raw=true",destfile=tmp, mode="wb")

#read that excel file  using readxl package's read excel function
raw_data<-readxl::read_excel(tmp,skip=7,col_names=FALSE)
head(raw_data)
tail(raw_data)
#remove  unrequired lines
raw_data <-raw_data %>% slice(-c(49,50))
#check again
tail(raw_data)
colnames(raw_data) <- c("brand_name","auto_dom","auto_imp","auto_total","comm_dom","comm_imp","comm_total","total_dom","total_imp","total_total")

car_data_dec_16 <- raw_data %>% mutate_if(is.numeric,funs(ifelse(is.na(.),0,.))) %>% mutate(year=2016,month=12)
print(car_data_dec_16,width=Inf)

Random Analysis


saveRDS(car_data_dec_16,file="C:/Users/ezegokce/Desktop/503/odd_retail_sales_2016_12_2.rds")

car_data_dec_16 %>% 
  filter(auto_total > 0 & comm_total > 0) %>%
  select(brand_name,total_total) %>%
  arrange(desc(total_total))

car_data_dec_16 %>%
  filter(total_total>100) %>%
  select(brand_name,total_total)%>%
   arrange(desc(total_total))