Understanding Turkeys Sectoral Card Transaction Changes In Six Month

The Interbank Card Center (BKM) was established in 1990 with the partnership of 13 public and private Turkish banks for the purpose of providing solutions to the common problems and developing the rules and standards of credit and debit cards in Turkey, within the card payment system.For further info please visit BKM website.

Gathering Civilized Data

To get last 6 months transaction data from BKM, I used rvest packege in for loop to follow the link pattern. After that data clearence process started in order to gather our civilized data.

library(rvest)
library(dplyr)
library(ggplot2)
url <- "https://bkm.com.tr/secilen-aya-ait-sektorel-gelisim/?filter_year=2019&filter_month=1"
page <- read_html(url)
tablo <- 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)
  tablo <- bind_rows(tablo, html_table(page, fill = TRUE)[[4]][-c(1:2),-1])}
is_yeri <- c(tablo%>% select(X1) %>%  filter(X1 != "NA"))
is_yeri_1 <- c(rep(is_yeri[["X1"]], times=6))
tablo_1 <- tablo %>% mutate(X1 = is_yeri_1) %>% filter(X1 != "TOPLAM")
month_1 <- c(rep(1:6, times=1, each=26))
tablo_son <- tablo_1 %>% mutate(month = month_1)
tablo2  <- as.data.frame(lapply(tablo_son, function(x) as.numeric(gsub(",", ".", gsub("\\.", "", x)))))
## Warning in FUN(X[[i]], ...): Zorlamadan dolayı ortaya çıkan NAs
tablo2[,1] <- tablo_son[,1]
tablo_son <- tablo2
colnames(tablo_son) <- c("isyeri_grubu","kredi_kartı_islem_adedi","banka_kartı_islem_adedi","kredi_kartı_islem_tutarı","banka_kartı_islem_tutarı","ay")