This document is an analysis of BKM data for the periods of January 2019 to June 2019. Data can be reached from https://bkm.com.tr/

Importing the Libraries

Firstly, we have to import libraries that we will use throughout the analysis.

library(rvest)
library(dplyr)
library(ggplot2)

Importing the Data

The file is downloaded from the link and is assigned to a new variable called “table”.

url <- "https://bkm.com.tr/secilen-aya-ait-sektorel-gelisim/?filter_year=2019&filter_month=1"
page <- read_html(url)
table <- 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)
  table <- bind_rows(table, html_table(page, fill = TRUE)[[4]][-c(1:2),-1])
}

temp1 <- c(table%>% select(X1) %>%  filter(X1 != "NA"))
temp2 <- c(rep(temp1[["X1"]], times=6))
temp3 <- as.character(c(rep(seq(1:26), times=6)))


tmpTable <- table %>% mutate(X1 = temp2) %>% filter(X1 != "TOPLAM") %>% mutate(X6=temp3)


month_1 <- c(rep(1:6, times=1, each=26))
table <- tmpTable %>% mutate(month = month_1)


table2  <- as.data.frame(lapply(table, function(x) as.numeric(gsub(",", ".", gsub("\\.", "", x)))))
table2[,1] <- tmpTable[,1]
table2[,6] <- tmpTable[,6]
table <- table2

names(table) <- c("Sector", "TransactionCount_CC", "TransactionCount_DC", "TransactionAmount_CC", "TransactionAmount_DC", "Sector_ID", "Month")

Now let’s have a look at the beginning and end of the variable “table”.

head(table)
##                                   Sector TransactionCount_CC
## 1                         ARABA KİRALAMA              256372
## 2 ARAÇ KİRALAMA-SATIŞ/SERVİS/YEDEK PARÇA             2967019
## 3           BENZİN VE YAKIT İSTASYONLARI            25277186
## 4                     BIREYSEL EMEKLILIK             2271587
## 5                           ÇEŞİTLİ GIDA            28362091
## 6                     DOĞRUDAN PAZARLAMA              757602
##   TransactionCount_DC TransactionAmount_CC TransactionAmount_DC Sector_ID
## 1               49296               195.13                14.77         1
## 2              642136              2185.84               127.16         2
## 3             8684036              5066.04               680.01         3
## 4                 697               716.42                 0.30         4
## 5            15221891              4473.98               673.70         5
## 6               40038               678.99                 7.81         6
##   Month
## 1     1
## 2     1
## 3     1
## 4     1
## 5     1
## 6     1
tail(table)
##                                    Sector TransactionCount_CC
## 151        SEYAHAT ACENTELERİ/TAŞIMACILIK             7224598
## 152                               SİGORTA             4513691
## 153                      TELEKOMÜNİKASYON            17915719
## 154 YAPI MALZEMELERİ, HIRDAVAT, NALBURİYE             3786201
## 155                                 YEMEK            45687937
## 156                                 DİĞER             4984660
##     TransactionCount_DC TransactionAmount_CC TransactionAmount_DC
## 151             3152401              2311.90               620.16
## 152               42440              2919.50                11.44
## 153             3236866              1720.25               247.08
## 154             1347371              2784.08               199.37
## 155            43035091              2918.06              1497.76
## 156             1072573              1414.83               170.06
##     Sector_ID Month
## 151        21     6
## 152        22     6
## 153        23     6
## 154        24     6
## 155        25     6
## 156        26     6