#Analyzing BKM Data
In this brief analysis you will be able to see some facts related to H1 2019 market dynamics of Turkey related to credit card transactions. I found the data from BKM website.Making a consolidated version of raw date of 6 months of 2019 year.
Necessary packagesfor having a comprehensive analysis are listed below:
library(rvest)
library(dplyr)
library(ggplot2)
library(tidyr)
library(zoo)
The methodology to grasp relevant document from an HTML source can be viewed from here:
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]], ...): NAs introduced by coercion
tablo2[,1] <- tablo_son[,1]
tablo_son <- tablo2
Finishing up the data tidying by renaming the column names and the data is now available for analysis.
cols <- c("workplace", "transaction_credit_card", "transaction_debit_card_", "amount_of_purchase_credit_card", "amount_of_purchase_debit_card", "month" )
colnames(tablo_son) <- cols
First and last rows of the dataset in below tables, respectively. ###
head(tablo_son)
## workplace transaction_credit_card
## 1 ARABA KIRALAMA 256372
## 2 ARAÇ KIRALAMA-SATIS/SERVIS/YEDEK PARÇA 2967019
## 3 BENZIN VE YAKIT ISTASYONLARI 25277186
## 4 BIREYSEL EMEKLILIK 2271587
## 5 ÇESITLI GIDA 28362091
## 6 DOGRUDAN PAZARLAMA 757602
## transaction_debit_card_ amount_of_purchase_credit_card
## 1 49296 195.13
## 2 642136 2185.84
## 3 8684036 5066.04
## 4 697 716.42
## 5 15221891 4473.98
## 6 40038 678.99
## amount_of_purchase_debit_card month
## 1 14.77 1
## 2 127.16 1
## 3 680.01 1
## 4 0.30 1
## 5 673.70 1
## 6 7.81 1
tail(tablo_son)
## workplace transaction_credit_card
## 151 SEYAHAT ACENTELERI/TASIMACILIK 7224598
## 152 SIGORTA 4513691
## 153 TELEKOMÜNIKASYON 17915719
## 154 YAPI MALZEMELERI, HIRDAVAT, NALBURIYE 3786201
## 155 YEMEK 45687937
## 156 DIGER 4984660
## transaction_debit_card_ amount_of_purchase_credit_card
## 151 3152401 2311.90
## 152 42440 2919.50
## 153 3236866 1720.25
## 154 1347371 2784.08
## 155 43035091 2918.06
## 156 1072573 1414.83
## amount_of_purchase_debit_card month
## 151 620.16 6
## 152 11.44 6
## 153 247.08 6
## 154 199.37 6
## 155 1497.76 6
## 156 170.06 6
Observing the monthly trend, may is the biggest transaction month, which is mostly because Ramadan month was held in May in 2019. since the biggest transaction takes place in grocery and shopping mall, Ramadan food transactions impacted this trend.
tablo_son %>%
filter(transaction_credit_card > 0 & transaction_debit_card_ > 0) %>%
select(transaction_credit_card,transaction_debit_card_,amount_of_purchase_credit_card,amount_of_purchase_debit_card,month) %>%
arrange(desc(month),desc(amount_of_purchase_credit_card)) %>%
group_by(month) %>%
summarize(month_total = sum(amount_of_purchase_debit_card, amount_of_purchase_credit_card)) %>%
arrange(desc(month_total))%>%
ggplot(data = ., aes(x = workplace, y = month_total,
fill = as.character(month))) + geom_bar(stat = "identity") + aes(x = reorder(month, -month_total),
y =month_total) + labs(x = "", y = "", title = "Monthly Transaction Volume by Scale") + theme_bw() + theme( axis.text.x = element_text(angle = 90,
vjust = 0.49, hjust = 0.49, size = 8)) + scale_y_continuous(labels = scales::comma) + scale_x_discrete(labels = c("May", "Jun","Mar", "Apr", "Jan", "Feb")) + theme(legend.position = "none")
Understanding grocery and shopping malls are the biggest source of both credit card and debit card transactions in Turkey in half one of year 2019.
tablo_son %>%
select(workplace, transaction_credit_card,transaction_debit_card_,amount_of_purchase_credit_card,amount_of_purchase_debit_card,month) %>%
group_by(workplace) %>%
summarize(sales=sum(transaction_credit_card, transaction_debit_card_)) %>%
mutate(share = round(sales/sum(sales),2)) %>%
arrange(desc(share)) %>%
print(share)
## # A tibble: 26 x 3
## workplace sales share
## <chr> <dbl> <dbl>
## 1 MARKET VE ALISVERIS MERKEZLERI 957742221 0.31
## 2 YEMEK 486166406 0.16
## 3 ÇESITLI GIDA 286302262 0.09
## 4 BENZIN VE YAKIT ISTASYONLARI 228279355 0.07
## 5 GIYIM VE AKSESUAR 226946321 0.07
## 6 HIZMET SEKTÖRLERI 174318580 0.06
## 7 SAGLIK/SAGLIK ÜRÜNLERI/KOZMETIK 132787104 0.04
## 8 TELEKOMÜNIKASYON 127338414 0.04
## 9 DIGER 88334580 0.03
## 10 EGITIM / KIRTASIYE / OFIS MALZEMELERI 50742892 0.02
## # ... with 16 more rows