Data contains “Sectoral Distribution of Expenditures in 6 Months in 2019”.
The web site is here: BKM-Secilen aya ait sektorel gelisim
library(tidyverse)
library(ggplot2)
library(rvest)
url <- "https://bkm.com.tr/secilen-aya-ait-sektorel-gelisim/?filter_year=2019&filter_month=1"
page <- read_html(url)
bkm_tablo_1 <- html_table(page, fill = TRUE)[[4]][-c(1:2),]
for(i in 2:6) {
url <- paste("https://bkm.com.tr/secilen-aya-ait-sektorel-gelisim/?filter_year=2019&filter_month=", i, sep = "")
page <- read_html(url)
bkm_tablo_1 <- bind_rows(bkm_tablo_1, html_table(page, fill = TRUE)[[4]][-c(1:2),-1])
}
sec <- c(bkm_tablo_1 %>% select(X1) %>% filter(X1 != "NA"))
sec_1 <- c(rep(sec[["X1"]], times=6))
bkm_tablo_2 <- bkm_tablo_1 %>% mutate(X1 = sec_1) %>% filter(X1 != "TOPLAM")
month_1 <- c(rep(1:6, times=1, each=26))
bkm_tablo_3 <- bkm_tablo_2 %>% mutate(Month = month_1)
bkm_tablo_4 <- as.data.frame(lapply(bkm_tablo_3, function(x) as.numeric(gsub(",", ".", gsub("\\.", "", x)))))
## Warning in FUN(X[[i]], ...): Zorlamadan dolayı ortaya çıkan NAs
bkm_tablo_4 [,1] <- bkm_tablo_3[,1]
colnames(bkm_tablo_4)<-c("Sector","CC_num","DC_num","CC_volume","DC_volume","Months")
head(bkm_tablo_4)
## Sector CC_num DC_num CC_volume
## 1 ARABA KİRALAMA 256372 49296 195.13
## 2 ARAÇ KİRALAMA-SATIŞ/SERVİS/YEDEK PARÇA 2967019 642136 2185.84
## 3 BENZİN VE YAKIT İSTASYONLARI 25277186 8684036 5066.04
## 4 BIREYSEL EMEKLILIK 2271587 697 716.42
## 5 ÇEŞİTLİ GIDA 28362091 15221891 4473.98
## 6 DOĞRUDAN PAZARLAMA 757602 40038 678.99
## DC_volume Months
## 1 14.77 1
## 2 127.16 1
## 3 680.01 1
## 4 0.30 1
## 5 673.70 1
## 6 7.81 1
focused <- c("ARABA KİRALAMA","ARAÇ KİRALAMA-SATIŞ/SERVİS/YEDEK PARÇA","BENZİN VE YAKIT İSTASYONLARI")
bkm_analysis_1 <- bkm_tablo_4 %>% filter(Sector %in% focused) %>% mutate(SUM_VOLUME = CC_volume + DC_volume) %>% group_by(Months)
ggplot(bkm_analysis_1,aes(x=Months, y=SUM_VOLUME, color=Sector)) +
geom_line()