The datasets is about Turkey’s tourism statistics. There are 3 different type of datasets including “Travel Incomes and Expenses”, “Distribution of Arriving Foreign Visitors According to Cities to Which Border Gates are Bound” and “Tourists by Nationalities”. In this project, these datasets will be analyzed between 2008-2021 years.
In this data set, the nationalities of the tourists who visited Turkey between January 2008 and September 2021 are shown.
library(lubridate)
library(tidyverse)
library(readr)
library(MASS)
library(reshape2)
library(reshape)
library(eeptools)
library(dplyr)
library(scales)
library(rmarkdown)
<- read_rds("https://raw.githubusercontent.com/pjournal/mef05g-r-u-mine/gh-pages/files/Tourists_by_nationalities2.rds")
tbn
head(tbn)
<- tbn[, 1:2]
tbn1 $ALMANYA <- NULL
tbn1<- apply(tbn[,2:103], FUN = decomma, MARGIN = 2)
tbn2 = cbind(tbn1,tbn2) result
We check the datatype and whether there is null values.
str(result)
## 'data.frame': 165 obs. of 103 variables:
## $ ï..Tarih : chr "2008/01" "2008/02" "2008/03" "2008/04" ...
## $ ALMANYA : num 177233 143666 249797 242531 399724 ...
## $ ARNAVUTLUK : num 2811 2604 3626 3219 4156 ...
## $ AVUSTURYA : num 20207 16295 23558 22668 32265 ...
## $ BELCIKA : num 12389 11309 21097 30772 50483 ...
## $ BOSNAHERSEK : num 2546 2342 2952 3539 4709 ...
## $ BULGARISTAN : num 99048 82707 102877 110627 148642 ...
## $ CEKCUMHURIYETI: num 1824 2064 2524 4198 9286 ...
## $ DANIMARKA : num 5613 5464 11288 10878 26008 ...
## $ ESTONYA : num 426 515 695 1098 4508 ...
## $ FINLANDIYA : num 1921 1723 4142 7661 12479 ...
## $ FRANSA : num 30796 29228 36832 73221 85549 ...
## $ GKIBRIS : num 296 369 435 527 888 ...
## $ HIRVATISTAN : num 2354 1738 2649 2384 2997 ...
## $ HOLLANDA : num 32012 23565 34660 47950 183312 ...
## $ INGILTERE : num 35215 33385 46445 85841 203340 ...
## $ IRLANDA : num 2086 1723 3593 3846 11936 ...
## $ ISPANYA : num 7724 8331 27664 20599 31934 ...
## $ ISVEC : num 8156 5808 11248 14843 47482 ...
## $ ISVICRE : num 9655 8947 13368 14681 22433 ...
## $ ITALYA : num 24918 15204 25805 34936 58499 ...
## $ IZLANDA : num 72 99 367 622 463 ...
## $ KARADAG : num 0 0 0 0 0 0 0 0 0 0 ...
## $ KOSOVA : num 0 0 0 0 0 0 0 0 0 0 ...
## $ LETONYA : num 1126 1309 2050 2251 6950 ...
## $ LITVANYA : num 1076 1198 2262 3400 14423 ...
## $ LUKSEMBURG : num 164 155 341 394 2813 ...
## $ MACARISTAN : num 2266 2281 3085 3974 5364 ...
## $ MAKEDONYA : num 5480 5253 5930 7985 8042 ...
## $ MALTA : num 114 110 280 259 242 262 284 701 545 274 ...
## $ NORVEC : num 3488 3203 8424 9692 22667 ...
## $ POLONYA : num 4543 5009 5100 9547 34855 ...
## $ PORTEKIZ : num 810 999 1849 2006 3393 ...
## $ ROMANYA : num 16966 21941 21451 26194 32095 ...
## $ SIRBISTAN : num 8449 7248 8441 9357 11950 ...
## $ SLOVAKYA : num 883 1379 1408 1957 2815 ...
## $ SLOVENYA : num 1279 1378 1322 1910 3649 ...
## $ YUNANISTAN : num 27656 21990 44384 46099 51656 ...
## $ DAVRUPA : num 91 60 145 133 170 230 289 320 188 300 ...
## $ AVRUPATOP : num 551693 470599 732094 861799 1542177 ...
## $ AZERBAYCAN : num 29978 33028 37111 35267 39946 ...
## $ BELARUS : num 1764 2999 3040 4130 14623 ...
## $ ERMENISTAN : num 2500 3586 3731 4011 4756 ...
## $ GURCISTAN : num 40517 43820 49739 57554 70673 ...
## $ KAZAKISTAN : num 6059 8777 8070 8178 12683 ...
## $ KIRGIZISTAN : num 3859 3398 3597 3474 3678 ...
## $ MOLDOVACUM : num 7769 9322 10433 11654 15074 ...
## $ OZBEKISTAN : num 3431 4520 4133 3991 4645 ...
## $ RUSYA : num 52741 46999 52034 64565 284720 ...
## $ TACIKISTAN : num 2965 4837 6169 4361 3873 ...
## $ TURKMENISTAN : num 5221 5407 6562 6825 6740 ...
## $ UKRAYNA : num 20789 21474 23654 29568 90428 ...
## $ BDTTOPLAM : num 177593 188167 208273 233578 551839 ...
## $ ABD : num 22581 18562 29479 38922 80430 ...
## $ ARJANTIN : num 662 612 789 916 2358 ...
## $ BREZILYA : num 1442 1446 1318 2387 5157 ...
## $ KANADA : num 3670 2981 5090 7395 18578 ...
## $ KOLOMBIYA : num 277 107 238 283 488 656 1080 536 942 769 ...
## $ MEKSIKA : num 720 546 1430 1501 2287 ...
## $ SILI : num 185 554 248 527 1094 ...
## $ VENEZUELLA : num 494 125 412 469 744 ...
## $ DAMERIKA : num 1590 1895 1857 2235 3368 ...
## $ AMERIKATOP : num 31621 26828 40861 54635 114504 ...
## $ CEZAYIR : num 3719 2825 3936 4898 5284 ...
## $ FAS : num 2088 2094 2338 2774 3274 ...
## $ GAFRIKA : num 586 578 1077 1267 2244 ...
## $ LIBYA : num 2526 1871 2672 3172 3379 ...
## $ MISIR : num 2320 3201 3412 3441 4073 ...
## $ SUDAN : num 329 220 336 330 562 931 693 938 415 704 ...
## $ TUNUS : num 2541 2216 3684 2877 4135 ...
## $ DAFRIKA : num 1164 1600 1709 1826 2807 ...
## $ AFRIKATOP : num 15273 14605 19164 20585 25758 ...
## $ BAE : num 568 252 605 405 617 ...
## $ BAHREYN : num 194 166 247 232 323 ...
## $ BANGLADES : num 226 357 245 224 267 356 455 263 305 420 ...
## $ CIN : num 3848 4972 4014 4586 6100 ...
## $ ENDONEZYA : num 545 486 910 1149 1500 ...
## $ FILIPINLER : num 1248 2018 2040 1971 2456 ...
## $ GKORE : num 13933 10652 8717 12782 12960 ...
## $ HINDISTAN : num 2825 2688 4180 4201 6783 ...
## $ IRAK : num 8771 10418 13165 12539 13530 ...
## $ IRAN : num 29120 36619 81837 63238 87791 ...
## $ ISRAIL : num 16500 19408 29858 50992 40665 ...
## $ JAPONYA : num 10985 11197 12858 11516 13258 ...
## $ KKTC : num 10696 15090 11621 14283 15258 ...
## $ KATAR : num 91 105 113 158 154 ...
## $ KUVEYT : num 275 478 256 896 884 ...
## $ LUBNAN : num 1836 1719 2842 3939 2565 ...
## $ MALEZYA : num 1153 1679 2424 1840 2614 ...
## $ PAKISTAN : num 1858 1685 1800 1746 2659 ...
## $ SINGAPUR : num 736 909 1117 1302 1693 ...
## $ SURIYE : num 24464 24949 27203 27704 30869 ...
## $ SUUDARABISTAN : num 721 1499 1016 2074 2025 ...
## $ TAYLAND : num 563 516 1003 1081 1005 ...
## $ URDUN : num 2787 2594 3280 3455 4336 ...
## $ YEMEN : num 116 299 287 331 444 ...
## $ DASYA : num 2921 3191 4073 4547 7854 ...
## $ ASYATOP : num 136980 153946 215711 227191 258610 ...
## $ AVUSTRALYA : num 4823 3254 3571 10084 13011 ...
## [list output truncated]
colSums(is.na(result))
## ï..Tarih ALMANYA ARNAVUTLUK AVUSTURYA BELCIKA
## 0 0 0 0 0
## BOSNAHERSEK BULGARISTAN CEKCUMHURIYETI DANIMARKA ESTONYA
## 0 0 0 0 0
## FINLANDIYA FRANSA GKIBRIS HIRVATISTAN HOLLANDA
## 0 0 0 0 0
## INGILTERE IRLANDA ISPANYA ISVEC ISVICRE
## 0 0 0 0 0
## ITALYA IZLANDA KARADAG KOSOVA LETONYA
## 0 0 0 0 0
## LITVANYA LUKSEMBURG MACARISTAN MAKEDONYA MALTA
## 0 0 0 0 0
## NORVEC POLONYA PORTEKIZ ROMANYA SIRBISTAN
## 0 0 0 0 0
## SLOVAKYA SLOVENYA YUNANISTAN DAVRUPA AVRUPATOP
## 0 0 0 0 0
## AZERBAYCAN BELARUS ERMENISTAN GURCISTAN KAZAKISTAN
## 0 0 0 0 0
## KIRGIZISTAN MOLDOVACUM OZBEKISTAN RUSYA TACIKISTAN
## 0 0 0 0 0
## TURKMENISTAN UKRAYNA BDTTOPLAM ABD ARJANTIN
## 0 0 0 0 0
## BREZILYA KANADA KOLOMBIYA MEKSIKA SILI
## 0 0 0 0 0
## VENEZUELLA DAMERIKA AMERIKATOP CEZAYIR FAS
## 0 0 0 0 0
## GAFRIKA LIBYA MISIR SUDAN TUNUS
## 0 0 0 0 0
## DAFRIKA AFRIKATOP BAE BAHREYN BANGLADES
## 0 0 0 0 0
## CIN ENDONEZYA FILIPINLER GKORE HINDISTAN
## 0 0 0 0 0
## IRAK IRAN ISRAIL JAPONYA KKTC
## 0 0 0 0 0
## KATAR KUVEYT LUBNAN MALEZYA PAKISTAN
## 0 0 0 0 0
## SINGAPUR SURIYE SUUDARABISTAN TAYLAND URDUN
## 0 0 0 0 0
## YEMEN DASYA ASYATOP AVUSTRALYA YENIZELLANDA
## 0 0 0 0 0
## OKYANUSYA MILLIYESIZ GTOPLAM
## 0 0 0
We change the date data type character to date time.
$ï..Tarih <- paste0(result$ï..Tarih,"/01")
result
str(result$ï..Tarih)
## chr [1:165] "2008/01/01" "2008/02/01" "2008/03/01" "2008/04/01" ...
$ï..Tarih <- as.Date(result$ï..Tarih, format = "%Y/%m/%d")
resultstr(result$ï..Tarih)
## Date[1:165], format: "2008-01-01" "2008-02-01" "2008-03-01" "2008-04-01" "2008-05-01" ...
str(result)
## 'data.frame': 165 obs. of 103 variables:
## $ ï..Tarih : Date, format: "2008-01-01" "2008-02-01" ...
## $ ALMANYA : num 177233 143666 249797 242531 399724 ...
## $ ARNAVUTLUK : num 2811 2604 3626 3219 4156 ...
## $ AVUSTURYA : num 20207 16295 23558 22668 32265 ...
## $ BELCIKA : num 12389 11309 21097 30772 50483 ...
## $ BOSNAHERSEK : num 2546 2342 2952 3539 4709 ...
## $ BULGARISTAN : num 99048 82707 102877 110627 148642 ...
## $ CEKCUMHURIYETI: num 1824 2064 2524 4198 9286 ...
## $ DANIMARKA : num 5613 5464 11288 10878 26008 ...
## $ ESTONYA : num 426 515 695 1098 4508 ...
## $ FINLANDIYA : num 1921 1723 4142 7661 12479 ...
## $ FRANSA : num 30796 29228 36832 73221 85549 ...
## $ GKIBRIS : num 296 369 435 527 888 ...
## $ HIRVATISTAN : num 2354 1738 2649 2384 2997 ...
## $ HOLLANDA : num 32012 23565 34660 47950 183312 ...
## $ INGILTERE : num 35215 33385 46445 85841 203340 ...
## $ IRLANDA : num 2086 1723 3593 3846 11936 ...
## $ ISPANYA : num 7724 8331 27664 20599 31934 ...
## $ ISVEC : num 8156 5808 11248 14843 47482 ...
## $ ISVICRE : num 9655 8947 13368 14681 22433 ...
## $ ITALYA : num 24918 15204 25805 34936 58499 ...
## $ IZLANDA : num 72 99 367 622 463 ...
## $ KARADAG : num 0 0 0 0 0 0 0 0 0 0 ...
## $ KOSOVA : num 0 0 0 0 0 0 0 0 0 0 ...
## $ LETONYA : num 1126 1309 2050 2251 6950 ...
## $ LITVANYA : num 1076 1198 2262 3400 14423 ...
## $ LUKSEMBURG : num 164 155 341 394 2813 ...
## $ MACARISTAN : num 2266 2281 3085 3974 5364 ...
## $ MAKEDONYA : num 5480 5253 5930 7985 8042 ...
## $ MALTA : num 114 110 280 259 242 262 284 701 545 274 ...
## $ NORVEC : num 3488 3203 8424 9692 22667 ...
## $ POLONYA : num 4543 5009 5100 9547 34855 ...
## $ PORTEKIZ : num 810 999 1849 2006 3393 ...
## $ ROMANYA : num 16966 21941 21451 26194 32095 ...
## $ SIRBISTAN : num 8449 7248 8441 9357 11950 ...
## $ SLOVAKYA : num 883 1379 1408 1957 2815 ...
## $ SLOVENYA : num 1279 1378 1322 1910 3649 ...
## $ YUNANISTAN : num 27656 21990 44384 46099 51656 ...
## $ DAVRUPA : num 91 60 145 133 170 230 289 320 188 300 ...
## $ AVRUPATOP : num 551693 470599 732094 861799 1542177 ...
## $ AZERBAYCAN : num 29978 33028 37111 35267 39946 ...
## $ BELARUS : num 1764 2999 3040 4130 14623 ...
## $ ERMENISTAN : num 2500 3586 3731 4011 4756 ...
## $ GURCISTAN : num 40517 43820 49739 57554 70673 ...
## $ KAZAKISTAN : num 6059 8777 8070 8178 12683 ...
## $ KIRGIZISTAN : num 3859 3398 3597 3474 3678 ...
## $ MOLDOVACUM : num 7769 9322 10433 11654 15074 ...
## $ OZBEKISTAN : num 3431 4520 4133 3991 4645 ...
## $ RUSYA : num 52741 46999 52034 64565 284720 ...
## $ TACIKISTAN : num 2965 4837 6169 4361 3873 ...
## $ TURKMENISTAN : num 5221 5407 6562 6825 6740 ...
## $ UKRAYNA : num 20789 21474 23654 29568 90428 ...
## $ BDTTOPLAM : num 177593 188167 208273 233578 551839 ...
## $ ABD : num 22581 18562 29479 38922 80430 ...
## $ ARJANTIN : num 662 612 789 916 2358 ...
## $ BREZILYA : num 1442 1446 1318 2387 5157 ...
## $ KANADA : num 3670 2981 5090 7395 18578 ...
## $ KOLOMBIYA : num 277 107 238 283 488 656 1080 536 942 769 ...
## $ MEKSIKA : num 720 546 1430 1501 2287 ...
## $ SILI : num 185 554 248 527 1094 ...
## $ VENEZUELLA : num 494 125 412 469 744 ...
## $ DAMERIKA : num 1590 1895 1857 2235 3368 ...
## $ AMERIKATOP : num 31621 26828 40861 54635 114504 ...
## $ CEZAYIR : num 3719 2825 3936 4898 5284 ...
## $ FAS : num 2088 2094 2338 2774 3274 ...
## $ GAFRIKA : num 586 578 1077 1267 2244 ...
## $ LIBYA : num 2526 1871 2672 3172 3379 ...
## $ MISIR : num 2320 3201 3412 3441 4073 ...
## $ SUDAN : num 329 220 336 330 562 931 693 938 415 704 ...
## $ TUNUS : num 2541 2216 3684 2877 4135 ...
## $ DAFRIKA : num 1164 1600 1709 1826 2807 ...
## $ AFRIKATOP : num 15273 14605 19164 20585 25758 ...
## $ BAE : num 568 252 605 405 617 ...
## $ BAHREYN : num 194 166 247 232 323 ...
## $ BANGLADES : num 226 357 245 224 267 356 455 263 305 420 ...
## $ CIN : num 3848 4972 4014 4586 6100 ...
## $ ENDONEZYA : num 545 486 910 1149 1500 ...
## $ FILIPINLER : num 1248 2018 2040 1971 2456 ...
## $ GKORE : num 13933 10652 8717 12782 12960 ...
## $ HINDISTAN : num 2825 2688 4180 4201 6783 ...
## $ IRAK : num 8771 10418 13165 12539 13530 ...
## $ IRAN : num 29120 36619 81837 63238 87791 ...
## $ ISRAIL : num 16500 19408 29858 50992 40665 ...
## $ JAPONYA : num 10985 11197 12858 11516 13258 ...
## $ KKTC : num 10696 15090 11621 14283 15258 ...
## $ KATAR : num 91 105 113 158 154 ...
## $ KUVEYT : num 275 478 256 896 884 ...
## $ LUBNAN : num 1836 1719 2842 3939 2565 ...
## $ MALEZYA : num 1153 1679 2424 1840 2614 ...
## $ PAKISTAN : num 1858 1685 1800 1746 2659 ...
## $ SINGAPUR : num 736 909 1117 1302 1693 ...
## $ SURIYE : num 24464 24949 27203 27704 30869 ...
## $ SUUDARABISTAN : num 721 1499 1016 2074 2025 ...
## $ TAYLAND : num 563 516 1003 1081 1005 ...
## $ URDUN : num 2787 2594 3280 3455 4336 ...
## $ YEMEN : num 116 299 287 331 444 ...
## $ DASYA : num 2921 3191 4073 4547 7854 ...
## $ ASYATOP : num 136980 153946 215711 227191 258610 ...
## $ AVUSTRALYA : num 4823 3254 3571 10084 13011 ...
## [list output truncated]
We delete total columns that we do not use.
= subset(result, select = -c(AFRIKATOP,AMERIKATOP,BDTTOPLAM,ASYATOP,AVRUPATOP,GTOPLAM,OKYANUSYA))
tbn_d str(tbn_d)
## 'data.frame': 165 obs. of 96 variables:
## $ ï..Tarih : Date, format: "2008-01-01" "2008-02-01" ...
## $ ALMANYA : num 177233 143666 249797 242531 399724 ...
## $ ARNAVUTLUK : num 2811 2604 3626 3219 4156 ...
## $ AVUSTURYA : num 20207 16295 23558 22668 32265 ...
## $ BELCIKA : num 12389 11309 21097 30772 50483 ...
## $ BOSNAHERSEK : num 2546 2342 2952 3539 4709 ...
## $ BULGARISTAN : num 99048 82707 102877 110627 148642 ...
## $ CEKCUMHURIYETI: num 1824 2064 2524 4198 9286 ...
## $ DANIMARKA : num 5613 5464 11288 10878 26008 ...
## $ ESTONYA : num 426 515 695 1098 4508 ...
## $ FINLANDIYA : num 1921 1723 4142 7661 12479 ...
## $ FRANSA : num 30796 29228 36832 73221 85549 ...
## $ GKIBRIS : num 296 369 435 527 888 ...
## $ HIRVATISTAN : num 2354 1738 2649 2384 2997 ...
## $ HOLLANDA : num 32012 23565 34660 47950 183312 ...
## $ INGILTERE : num 35215 33385 46445 85841 203340 ...
## $ IRLANDA : num 2086 1723 3593 3846 11936 ...
## $ ISPANYA : num 7724 8331 27664 20599 31934 ...
## $ ISVEC : num 8156 5808 11248 14843 47482 ...
## $ ISVICRE : num 9655 8947 13368 14681 22433 ...
## $ ITALYA : num 24918 15204 25805 34936 58499 ...
## $ IZLANDA : num 72 99 367 622 463 ...
## $ KARADAG : num 0 0 0 0 0 0 0 0 0 0 ...
## $ KOSOVA : num 0 0 0 0 0 0 0 0 0 0 ...
## $ LETONYA : num 1126 1309 2050 2251 6950 ...
## $ LITVANYA : num 1076 1198 2262 3400 14423 ...
## $ LUKSEMBURG : num 164 155 341 394 2813 ...
## $ MACARISTAN : num 2266 2281 3085 3974 5364 ...
## $ MAKEDONYA : num 5480 5253 5930 7985 8042 ...
## $ MALTA : num 114 110 280 259 242 262 284 701 545 274 ...
## $ NORVEC : num 3488 3203 8424 9692 22667 ...
## $ POLONYA : num 4543 5009 5100 9547 34855 ...
## $ PORTEKIZ : num 810 999 1849 2006 3393 ...
## $ ROMANYA : num 16966 21941 21451 26194 32095 ...
## $ SIRBISTAN : num 8449 7248 8441 9357 11950 ...
## $ SLOVAKYA : num 883 1379 1408 1957 2815 ...
## $ SLOVENYA : num 1279 1378 1322 1910 3649 ...
## $ YUNANISTAN : num 27656 21990 44384 46099 51656 ...
## $ DAVRUPA : num 91 60 145 133 170 230 289 320 188 300 ...
## $ AZERBAYCAN : num 29978 33028 37111 35267 39946 ...
## $ BELARUS : num 1764 2999 3040 4130 14623 ...
## $ ERMENISTAN : num 2500 3586 3731 4011 4756 ...
## $ GURCISTAN : num 40517 43820 49739 57554 70673 ...
## $ KAZAKISTAN : num 6059 8777 8070 8178 12683 ...
## $ KIRGIZISTAN : num 3859 3398 3597 3474 3678 ...
## $ MOLDOVACUM : num 7769 9322 10433 11654 15074 ...
## $ OZBEKISTAN : num 3431 4520 4133 3991 4645 ...
## $ RUSYA : num 52741 46999 52034 64565 284720 ...
## $ TACIKISTAN : num 2965 4837 6169 4361 3873 ...
## $ TURKMENISTAN : num 5221 5407 6562 6825 6740 ...
## $ UKRAYNA : num 20789 21474 23654 29568 90428 ...
## $ ABD : num 22581 18562 29479 38922 80430 ...
## $ ARJANTIN : num 662 612 789 916 2358 ...
## $ BREZILYA : num 1442 1446 1318 2387 5157 ...
## $ KANADA : num 3670 2981 5090 7395 18578 ...
## $ KOLOMBIYA : num 277 107 238 283 488 656 1080 536 942 769 ...
## $ MEKSIKA : num 720 546 1430 1501 2287 ...
## $ SILI : num 185 554 248 527 1094 ...
## $ VENEZUELLA : num 494 125 412 469 744 ...
## $ DAMERIKA : num 1590 1895 1857 2235 3368 ...
## $ CEZAYIR : num 3719 2825 3936 4898 5284 ...
## $ FAS : num 2088 2094 2338 2774 3274 ...
## $ GAFRIKA : num 586 578 1077 1267 2244 ...
## $ LIBYA : num 2526 1871 2672 3172 3379 ...
## $ MISIR : num 2320 3201 3412 3441 4073 ...
## $ SUDAN : num 329 220 336 330 562 931 693 938 415 704 ...
## $ TUNUS : num 2541 2216 3684 2877 4135 ...
## $ DAFRIKA : num 1164 1600 1709 1826 2807 ...
## $ BAE : num 568 252 605 405 617 ...
## $ BAHREYN : num 194 166 247 232 323 ...
## $ BANGLADES : num 226 357 245 224 267 356 455 263 305 420 ...
## $ CIN : num 3848 4972 4014 4586 6100 ...
## $ ENDONEZYA : num 545 486 910 1149 1500 ...
## $ FILIPINLER : num 1248 2018 2040 1971 2456 ...
## $ GKORE : num 13933 10652 8717 12782 12960 ...
## $ HINDISTAN : num 2825 2688 4180 4201 6783 ...
## $ IRAK : num 8771 10418 13165 12539 13530 ...
## $ IRAN : num 29120 36619 81837 63238 87791 ...
## $ ISRAIL : num 16500 19408 29858 50992 40665 ...
## $ JAPONYA : num 10985 11197 12858 11516 13258 ...
## $ KKTC : num 10696 15090 11621 14283 15258 ...
## $ KATAR : num 91 105 113 158 154 ...
## $ KUVEYT : num 275 478 256 896 884 ...
## $ LUBNAN : num 1836 1719 2842 3939 2565 ...
## $ MALEZYA : num 1153 1679 2424 1840 2614 ...
## $ PAKISTAN : num 1858 1685 1800 1746 2659 ...
## $ SINGAPUR : num 736 909 1117 1302 1693 ...
## $ SURIYE : num 24464 24949 27203 27704 30869 ...
## $ SUUDARABISTAN : num 721 1499 1016 2074 2025 ...
## $ TAYLAND : num 563 516 1003 1081 1005 ...
## $ URDUN : num 2787 2594 3280 3455 4336 ...
## $ YEMEN : num 116 299 287 331 444 ...
## $ DASYA : num 2921 3191 4073 4547 7854 ...
## $ AVUSTRALYA : num 4823 3254 3571 10084 13011 ...
## $ YENIZELLANDA : num 497 394 592 2249 2606 ...
## $ MILLIYESIZ : num 1056 947 1233 1304 1481 ...
colSums(is.na(tbn_d))
## ï..Tarih ALMANYA ARNAVUTLUK AVUSTURYA BELCIKA
## 0 0 0 0 0
## BOSNAHERSEK BULGARISTAN CEKCUMHURIYETI DANIMARKA ESTONYA
## 0 0 0 0 0
## FINLANDIYA FRANSA GKIBRIS HIRVATISTAN HOLLANDA
## 0 0 0 0 0
## INGILTERE IRLANDA ISPANYA ISVEC ISVICRE
## 0 0 0 0 0
## ITALYA IZLANDA KARADAG KOSOVA LETONYA
## 0 0 0 0 0
## LITVANYA LUKSEMBURG MACARISTAN MAKEDONYA MALTA
## 0 0 0 0 0
## NORVEC POLONYA PORTEKIZ ROMANYA SIRBISTAN
## 0 0 0 0 0
## SLOVAKYA SLOVENYA YUNANISTAN DAVRUPA AZERBAYCAN
## 0 0 0 0 0
## BELARUS ERMENISTAN GURCISTAN KAZAKISTAN KIRGIZISTAN
## 0 0 0 0 0
## MOLDOVACUM OZBEKISTAN RUSYA TACIKISTAN TURKMENISTAN
## 0 0 0 0 0
## UKRAYNA ABD ARJANTIN BREZILYA KANADA
## 0 0 0 0 0
## KOLOMBIYA MEKSIKA SILI VENEZUELLA DAMERIKA
## 0 0 0 0 0
## CEZAYIR FAS GAFRIKA LIBYA MISIR
## 0 0 0 0 0
## SUDAN TUNUS DAFRIKA BAE BAHREYN
## 0 0 0 0 0
## BANGLADES CIN ENDONEZYA FILIPINLER GKORE
## 0 0 0 0 0
## HINDISTAN IRAK IRAN ISRAIL JAPONYA
## 0 0 0 0 0
## KKTC KATAR KUVEYT LUBNAN MALEZYA
## 0 0 0 0 0
## PAKISTAN SINGAPUR SURIYE SUUDARABISTAN TAYLAND
## 0 0 0 0 0
## URDUN YEMEN DASYA AVUSTRALYA YENIZELLANDA
## 0 0 0 0 0
## MILLIYESIZ
## 0
Rename date column
names(tbn_d)[names(tbn_d) == "ï..Tarih"] <- "Tarih"
We convert the column to rows by using melt function.
<- melt(tbn_d, id.vars = "Tarih")
tbn_melt
colSums(is.na(tbn_melt))
## Tarih variable value
## 0 0 0
We create the null column and assign the continental names according to the country areas.
$Continental <- NA
tbn_melt$Continental[which(tbn_melt$variable %in% tbn_melt$variable[1:6270])] <- "EUROPE"
tbn_melt$Continental[which(tbn_melt$variable %in% c("BELARUS", "MOLDOVACUM", "RUSYA", "UKRAYNA","GURCISTAN"))] <- "EUROPE"
tbn_melt$Continental[which(tbn_melt$variable %in% c("AZERBAYCAN","ERMENISTAN","KAZAKISTAN","KIRGIZISTAN","OZBEKISTAN","TACIKISTAN","TURKMENISTAN"))] <- "ASIA"
tbn_melt$Continental[which(tbn_melt$variable %in% tbn_melt$variable[8251:9735])] <- "AMERICA"
tbn_melt$Continental[which(tbn_melt$variable %in% tbn_melt$variable[9736:11055])] <- "AFRICA"
tbn_melt$Continental[which(tbn_melt$variable %in% tbn_melt$variable[11056:15180])] <- "ASIA"
tbn_melt$Continental[which(tbn_melt$variable %in% tbn_melt$variable[15180:15510])] <- "AUSTRALIA"
tbn_melt$Continental[which(tbn_melt$variable %in% c("MILLIYESIZ"))] <- "MILLIYETSIZ"
tbn_melt
str(tbn_melt)
## 'data.frame': 15675 obs. of 4 variables:
## $ Tarih : Date, format: "2008-01-01" "2008-02-01" ...
## $ variable : Factor w/ 95 levels "ALMANYA","ARNAVUTLUK",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ value : num 177233 143666 249797 242531 399724 ...
## $ Continental: chr "EUROPE" "EUROPE" "EUROPE" "EUROPE" ...
We convert the character type to factor and rename country column.
$Continental <- as.factor(tbn_melt$Continental)
tbn_meltnames(tbn_melt)[names(tbn_melt) == "variable"] <- "Country"
We show the total numbers of the tourist based on continentals between 2008-2021 years. We say that the tourist come from Europe more than others.
<- tbn_melt %>% mutate(Year = format(tbn_melt$Tarih, "%Y")) %>%
tbn_cont group_by(Year, Continental) %>% summarise(total = sum(value))
ggplot(tbn_cont, aes(x = Continental, y = total, fill =Continental)) + geom_bar(stat="identity",aes(fill= Continental)) +
theme(axis.text.x = element_text(angle = 90)) +
expand_limits( x = c(0,NA), y = c(0,NA)) +
scale_y_continuous(labels = function(l) {
paste0(round(l/1e6,1),"m")
})
The European continent appears to have the largest percentage.
<- tbn_melt %>% group_by(Continental) %>% summarise(total = sum(value)) %>%
tbn_pie mutate(perc = `total` / sum(`total`)) %>%
mutate(labels = scales::percent(perc))
ggplot(tbn_pie, aes(x = "", y = labels, fill = Continental)) +
geom_col() +
geom_label(aes(label = labels),
position = position_stack(vjust = 0.5),
show.legend = FALSE) +
guides(fill = guide_legend(title = "Continental")) +
scale_fill_viridis_d() +
coord_polar(theta = "y") +
theme_void()
Dataset showing the distribution of foreign tourists visited Turkey between 2008 and 2021 according to the customs gates.
library(treemap)
library(treemapify)
<- read_rds("https://raw.githubusercontent.com/pjournal/mef05g-r-u-mine/gh-pages/files/distribution_border.rds")
df
$TOPLAM <- NULL
df
<- df[, 1:2]
df1 $ADANA <- NULL
df1<- apply(df[,2:82], FUN = decomma, MARGIN = 2)
df2 = cbind(df1,df2)
db
str(db)
## 'data.frame': 165 obs. of 82 variables:
## $ Tarih : chr "2008/01" "2008/02" "2008/03" "2008/04" ...
## $ ADANA : num 5996 6169 5496 5991 10403 ...
## $ ADIYAMAN : num 0 0 0 0 0 0 0 0 0 0 ...
## $ AFYON : num 0 0 0 0 0 0 0 0 0 0 ...
## $ AGRI : num 9642 14390 46563 34457 47046 ...
## $ AMASYA : num 0 0 0 0 0 0 0 0 0 0 ...
## $ ANKARA : num 16920 19524 23033 24198 29714 ...
## $ ANTALYA : num 121458 152011 291077 473912 1037876 ...
## $ ARTVIN : num 43235 42846 50674 57445 69285 ...
## $ AYDIN : num 80 83 8139 25818 70702 ...
## $ BALIKESIR : num 465 296 506 852 369 ...
## $ BILECIK : num 0 0 0 0 0 0 0 0 0 0 ...
## $ BINGOL : num 0 0 0 0 0 0 0 0 0 0 ...
## $ BITLIS : num 0 0 0 0 0 0 0 0 0 0 ...
## $ BOLU : num 0 0 0 0 0 0 0 0 0 0 ...
## $ BURDUR : num 0 0 0 0 0 0 0 0 0 0 ...
## $ BURSA : num 2383 63 48 100 57 ...
## $ CANAKKALE : num 28 114 570 882 75 ...
## $ CANKIRI : num 0 0 0 0 0 0 0 0 0 0 ...
## $ CORUM : num 0 0 0 0 0 0 0 0 0 0 ...
## $ DENIZLI : num 4 0 0 0 0 0 0 0 0 0 ...
## $ DIYARBAKIR: num 1 0 0 1 0 0 0 5 0 0 ...
## $ EDIRNE : num 100303 108488 138234 166926 173116 ...
## $ ELAZIG : num 0 0 0 0 0 0 0 0 0 0 ...
## $ ERZINCAN : num 0 0 0 0 0 0 0 0 0 0 ...
## $ ERZURUM : num 2356 2013 948 29 325 ...
## $ ESKISEHIR : num 0 0 0 0 187 234 531 390 116 117 ...
## $ GAZIANTEP : num 2080 2378 3726 4431 6236 ...
## $ GIRESUN : num 52 69 92 168 93 54 50 64 46 100 ...
## $ GUMUSHANE : num 0 0 0 0 0 0 0 0 0 0 ...
## $ HAKKARI : num 5033 4653 9754 5662 6657 ...
## $ HATAY : num 19645 16191 18173 18440 19980 ...
## $ ISPARTA : num 0 0 463 0 0 ...
## $ MERSIN : num 636 656 715 1760 1206 ...
## $ ISTANBUL : num 357219 431766 550358 582780 691409 ...
## $ IZMIR : num 22678 24000 41647 63460 118275 ...
## $ KARS : num 0 0 0 0 0 0 0 93 113 104 ...
## $ KASTAMONU : num 0 0 0 0 0 0 1 0 0 2 ...
## $ KAYSERI : num 937 1034 1370 1478 2727 ...
## $ KIRKLARELI: num 10367 13294 17426 23793 25793 ...
## $ KIRSEHIR : num 0 0 0 0 0 0 0 0 0 0 ...
## $ KOCAELI : num 294 240 398 291 354 374 420 316 301 303 ...
## $ KONYA : num 62 51 200 8 103 ...
## $ KUTAHYA : num 0 0 0 0 0 0 0 0 0 0 ...
## $ MALATYA : num 0 0 0 0 0 0 0 0 0 0 ...
## $ MANISA : num 0 0 0 0 0 0 0 0 0 0 ...
## $ MARAS : num 0 0 0 0 0 0 0 0 0 0 ...
## $ MARDIN : num 2254 1900 2494 2716 2979 ...
## $ MUGLA : num 9575 7985 20257 77717 340760 ...
## $ MUS : num 0 0 0 0 0 0 0 0 0 0 ...
## $ NEVSEHIR : num 0 0 736 6403 4217 ...
## $ NIGDE : num 0 0 0 0 0 0 0 0 0 0 ...
## $ ORDU : num 79 163 123 80 122 443 65 82 54 50 ...
## $ RIZE : num 0 1 2 3 0 3 0 0 3 0 ...
## $ SAKARYA : num 0 0 0 0 0 0 0 0 0 0 ...
## $ SAMSUN : num 1041 244 1550 1575 1979 ...
## $ SIIRT : num 0 0 0 0 0 0 0 0 0 0 ...
## $ SINOP : num 0 0 0 742 7 3 751 786 367 561 ...
## $ SIVAS : num 0 0 0 0 144 372 687 344 71 8 ...
## $ TEKIRDAG : num 1394 1598 1742 1754 2162 ...
## $ TOKAT : num 0 0 0 0 0 0 0 0 0 0 ...
## $ TRABZON : num 1128 1043 1100 1359 1637 ...
## $ TUNCELI : num 0 0 0 0 0 0 0 0 0 0 ...
## $ URFA : num 548 626 767 804 991 ...
## $ USAK : num 0 0 0 0 0 0 0 0 0 8 ...
## $ VAN : num 818 1235 2270 1472 1740 ...
## $ YOZGAT : num 0 0 0 0 0 0 0 0 0 0 ...
## $ ZONGULDAK : num 298 320 418 447 344 409 461 344 271 455 ...
## $ AKSARAY : num 0 0 0 0 0 0 0 0 0 0 ...
## $ BAYBURT : num 0 0 0 0 0 0 0 0 0 0 ...
## $ KARAMAN : num 0 0 0 0 0 0 0 0 0 0 ...
## $ KIRIKKALE : num 0 0 0 0 0 0 0 0 0 0 ...
## $ BATMAN : num 0 0 0 0 0 0 0 0 0 0 ...
## $ SIRNAK : num 6896 8242 10787 11411 11977 ...
## $ BARTIN : num 1 4 0 4 5 2 5 4 4 8 ...
## $ ARDAHAN : num 209 174 359 702 974 ...
## $ IGDIR : num 18666 19072 17850 19436 22071 ...
## $ YALOVA : num 0 0 0 0 0 0 0 0 0 0 ...
## $ KARABUK : num 0 0 0 0 0 0 0 0 0 0 ...
## $ KILIS : num 18005 13546 35232 28396 44467 ...
## $ OSMANIYE : num 0 0 0 0 0 0 0 0 0 0 ...
## $ DUZCE : num 0 0 0 0 0 0 0 0 0 0 ...
colSums(is.na(db))
## Tarih ADANA ADIYAMAN AFYON AGRI AMASYA ANKARA
## 0 0 0 0 0 0 0
## ANTALYA ARTVIN AYDIN BALIKESIR BILECIK BINGOL BITLIS
## 0 0 0 0 0 0 0
## BOLU BURDUR BURSA CANAKKALE CANKIRI CORUM DENIZLI
## 0 0 0 0 0 0 0
## DIYARBAKIR EDIRNE ELAZIG ERZINCAN ERZURUM ESKISEHIR GAZIANTEP
## 0 0 0 0 0 0 0
## GIRESUN GUMUSHANE HAKKARI HATAY ISPARTA MERSIN ISTANBUL
## 0 0 0 0 0 0 0
## IZMIR KARS KASTAMONU KAYSERI KIRKLARELI KIRSEHIR KOCAELI
## 0 0 0 0 0 1 0
## KONYA KUTAHYA MALATYA MANISA MARAS MARDIN MUGLA
## 0 0 0 0 0 0 0
## MUS NEVSEHIR NIGDE ORDU RIZE SAKARYA SAMSUN
## 0 0 1 0 0 0 0
## SIIRT SINOP SIVAS TEKIRDAG TOKAT TRABZON TUNCELI
## 0 0 0 0 0 0 0
## URFA USAK VAN YOZGAT ZONGULDAK AKSARAY BAYBURT
## 0 1 0 0 0 0 0
## KARAMAN KIRIKKALE BATMAN SIRNAK BARTIN ARDAHAN IGDIR
## 0 0 1 0 0 0 0
## YALOVA KARABUK KILIS OSMANIYE DUZCE
## 0 1 0 0 0
$Tarih <- paste0(db$Tarih,"/01")
db
str(db$Tarih)
## chr [1:165] "2008/01/01" "2008/02/01" "2008/03/01" "2008/04/01" ...
$Tarih <- as.Date(db$Tarih, format = "%Y/%m/%d")
dbstr(db$Tarih)
## Date[1:165], format: "2008-01-01" "2008-02-01" "2008-03-01" "2008-04-01" "2008-05-01" ...
str(db)
## 'data.frame': 165 obs. of 82 variables:
## $ Tarih : Date, format: "2008-01-01" "2008-02-01" ...
## $ ADANA : num 5996 6169 5496 5991 10403 ...
## $ ADIYAMAN : num 0 0 0 0 0 0 0 0 0 0 ...
## $ AFYON : num 0 0 0 0 0 0 0 0 0 0 ...
## $ AGRI : num 9642 14390 46563 34457 47046 ...
## $ AMASYA : num 0 0 0 0 0 0 0 0 0 0 ...
## $ ANKARA : num 16920 19524 23033 24198 29714 ...
## $ ANTALYA : num 121458 152011 291077 473912 1037876 ...
## $ ARTVIN : num 43235 42846 50674 57445 69285 ...
## $ AYDIN : num 80 83 8139 25818 70702 ...
## $ BALIKESIR : num 465 296 506 852 369 ...
## $ BILECIK : num 0 0 0 0 0 0 0 0 0 0 ...
## $ BINGOL : num 0 0 0 0 0 0 0 0 0 0 ...
## $ BITLIS : num 0 0 0 0 0 0 0 0 0 0 ...
## $ BOLU : num 0 0 0 0 0 0 0 0 0 0 ...
## $ BURDUR : num 0 0 0 0 0 0 0 0 0 0 ...
## $ BURSA : num 2383 63 48 100 57 ...
## $ CANAKKALE : num 28 114 570 882 75 ...
## $ CANKIRI : num 0 0 0 0 0 0 0 0 0 0 ...
## $ CORUM : num 0 0 0 0 0 0 0 0 0 0 ...
## $ DENIZLI : num 4 0 0 0 0 0 0 0 0 0 ...
## $ DIYARBAKIR: num 1 0 0 1 0 0 0 5 0 0 ...
## $ EDIRNE : num 100303 108488 138234 166926 173116 ...
## $ ELAZIG : num 0 0 0 0 0 0 0 0 0 0 ...
## $ ERZINCAN : num 0 0 0 0 0 0 0 0 0 0 ...
## $ ERZURUM : num 2356 2013 948 29 325 ...
## $ ESKISEHIR : num 0 0 0 0 187 234 531 390 116 117 ...
## $ GAZIANTEP : num 2080 2378 3726 4431 6236 ...
## $ GIRESUN : num 52 69 92 168 93 54 50 64 46 100 ...
## $ GUMUSHANE : num 0 0 0 0 0 0 0 0 0 0 ...
## $ HAKKARI : num 5033 4653 9754 5662 6657 ...
## $ HATAY : num 19645 16191 18173 18440 19980 ...
## $ ISPARTA : num 0 0 463 0 0 ...
## $ MERSIN : num 636 656 715 1760 1206 ...
## $ ISTANBUL : num 357219 431766 550358 582780 691409 ...
## $ IZMIR : num 22678 24000 41647 63460 118275 ...
## $ KARS : num 0 0 0 0 0 0 0 93 113 104 ...
## $ KASTAMONU : num 0 0 0 0 0 0 1 0 0 2 ...
## $ KAYSERI : num 937 1034 1370 1478 2727 ...
## $ KIRKLARELI: num 10367 13294 17426 23793 25793 ...
## $ KIRSEHIR : num 0 0 0 0 0 0 0 0 0 0 ...
## $ KOCAELI : num 294 240 398 291 354 374 420 316 301 303 ...
## $ KONYA : num 62 51 200 8 103 ...
## $ KUTAHYA : num 0 0 0 0 0 0 0 0 0 0 ...
## $ MALATYA : num 0 0 0 0 0 0 0 0 0 0 ...
## $ MANISA : num 0 0 0 0 0 0 0 0 0 0 ...
## $ MARAS : num 0 0 0 0 0 0 0 0 0 0 ...
## $ MARDIN : num 2254 1900 2494 2716 2979 ...
## $ MUGLA : num 9575 7985 20257 77717 340760 ...
## $ MUS : num 0 0 0 0 0 0 0 0 0 0 ...
## $ NEVSEHIR : num 0 0 736 6403 4217 ...
## $ NIGDE : num 0 0 0 0 0 0 0 0 0 0 ...
## $ ORDU : num 79 163 123 80 122 443 65 82 54 50 ...
## $ RIZE : num 0 1 2 3 0 3 0 0 3 0 ...
## $ SAKARYA : num 0 0 0 0 0 0 0 0 0 0 ...
## $ SAMSUN : num 1041 244 1550 1575 1979 ...
## $ SIIRT : num 0 0 0 0 0 0 0 0 0 0 ...
## $ SINOP : num 0 0 0 742 7 3 751 786 367 561 ...
## $ SIVAS : num 0 0 0 0 144 372 687 344 71 8 ...
## $ TEKIRDAG : num 1394 1598 1742 1754 2162 ...
## $ TOKAT : num 0 0 0 0 0 0 0 0 0 0 ...
## $ TRABZON : num 1128 1043 1100 1359 1637 ...
## $ TUNCELI : num 0 0 0 0 0 0 0 0 0 0 ...
## $ URFA : num 548 626 767 804 991 ...
## $ USAK : num 0 0 0 0 0 0 0 0 0 8 ...
## $ VAN : num 818 1235 2270 1472 1740 ...
## $ YOZGAT : num 0 0 0 0 0 0 0 0 0 0 ...
## $ ZONGULDAK : num 298 320 418 447 344 409 461 344 271 455 ...
## $ AKSARAY : num 0 0 0 0 0 0 0 0 0 0 ...
## $ BAYBURT : num 0 0 0 0 0 0 0 0 0 0 ...
## $ KARAMAN : num 0 0 0 0 0 0 0 0 0 0 ...
## $ KIRIKKALE : num 0 0 0 0 0 0 0 0 0 0 ...
## $ BATMAN : num 0 0 0 0 0 0 0 0 0 0 ...
## $ SIRNAK : num 6896 8242 10787 11411 11977 ...
## $ BARTIN : num 1 4 0 4 5 2 5 4 4 8 ...
## $ ARDAHAN : num 209 174 359 702 974 ...
## $ IGDIR : num 18666 19072 17850 19436 22071 ...
## $ YALOVA : num 0 0 0 0 0 0 0 0 0 0 ...
## $ KARABUK : num 0 0 0 0 0 0 0 0 0 0 ...
## $ KILIS : num 18005 13546 35232 28396 44467 ...
## $ OSMANIYE : num 0 0 0 0 0 0 0 0 0 0 ...
## $ DUZCE : num 0 0 0 0 0 0 0 0 0 0 ...
<- melt(db, id.vars = "Tarih")
db_melt str(db)
## 'data.frame': 165 obs. of 82 variables:
## $ Tarih : Date, format: "2008-01-01" "2008-02-01" ...
## $ ADANA : num 5996 6169 5496 5991 10403 ...
## $ ADIYAMAN : num 0 0 0 0 0 0 0 0 0 0 ...
## $ AFYON : num 0 0 0 0 0 0 0 0 0 0 ...
## $ AGRI : num 9642 14390 46563 34457 47046 ...
## $ AMASYA : num 0 0 0 0 0 0 0 0 0 0 ...
## $ ANKARA : num 16920 19524 23033 24198 29714 ...
## $ ANTALYA : num 121458 152011 291077 473912 1037876 ...
## $ ARTVIN : num 43235 42846 50674 57445 69285 ...
## $ AYDIN : num 80 83 8139 25818 70702 ...
## $ BALIKESIR : num 465 296 506 852 369 ...
## $ BILECIK : num 0 0 0 0 0 0 0 0 0 0 ...
## $ BINGOL : num 0 0 0 0 0 0 0 0 0 0 ...
## $ BITLIS : num 0 0 0 0 0 0 0 0 0 0 ...
## $ BOLU : num 0 0 0 0 0 0 0 0 0 0 ...
## $ BURDUR : num 0 0 0 0 0 0 0 0 0 0 ...
## $ BURSA : num 2383 63 48 100 57 ...
## $ CANAKKALE : num 28 114 570 882 75 ...
## $ CANKIRI : num 0 0 0 0 0 0 0 0 0 0 ...
## $ CORUM : num 0 0 0 0 0 0 0 0 0 0 ...
## $ DENIZLI : num 4 0 0 0 0 0 0 0 0 0 ...
## $ DIYARBAKIR: num 1 0 0 1 0 0 0 5 0 0 ...
## $ EDIRNE : num 100303 108488 138234 166926 173116 ...
## $ ELAZIG : num 0 0 0 0 0 0 0 0 0 0 ...
## $ ERZINCAN : num 0 0 0 0 0 0 0 0 0 0 ...
## $ ERZURUM : num 2356 2013 948 29 325 ...
## $ ESKISEHIR : num 0 0 0 0 187 234 531 390 116 117 ...
## $ GAZIANTEP : num 2080 2378 3726 4431 6236 ...
## $ GIRESUN : num 52 69 92 168 93 54 50 64 46 100 ...
## $ GUMUSHANE : num 0 0 0 0 0 0 0 0 0 0 ...
## $ HAKKARI : num 5033 4653 9754 5662 6657 ...
## $ HATAY : num 19645 16191 18173 18440 19980 ...
## $ ISPARTA : num 0 0 463 0 0 ...
## $ MERSIN : num 636 656 715 1760 1206 ...
## $ ISTANBUL : num 357219 431766 550358 582780 691409 ...
## $ IZMIR : num 22678 24000 41647 63460 118275 ...
## $ KARS : num 0 0 0 0 0 0 0 93 113 104 ...
## $ KASTAMONU : num 0 0 0 0 0 0 1 0 0 2 ...
## $ KAYSERI : num 937 1034 1370 1478 2727 ...
## $ KIRKLARELI: num 10367 13294 17426 23793 25793 ...
## $ KIRSEHIR : num 0 0 0 0 0 0 0 0 0 0 ...
## $ KOCAELI : num 294 240 398 291 354 374 420 316 301 303 ...
## $ KONYA : num 62 51 200 8 103 ...
## $ KUTAHYA : num 0 0 0 0 0 0 0 0 0 0 ...
## $ MALATYA : num 0 0 0 0 0 0 0 0 0 0 ...
## $ MANISA : num 0 0 0 0 0 0 0 0 0 0 ...
## $ MARAS : num 0 0 0 0 0 0 0 0 0 0 ...
## $ MARDIN : num 2254 1900 2494 2716 2979 ...
## $ MUGLA : num 9575 7985 20257 77717 340760 ...
## $ MUS : num 0 0 0 0 0 0 0 0 0 0 ...
## $ NEVSEHIR : num 0 0 736 6403 4217 ...
## $ NIGDE : num 0 0 0 0 0 0 0 0 0 0 ...
## $ ORDU : num 79 163 123 80 122 443 65 82 54 50 ...
## $ RIZE : num 0 1 2 3 0 3 0 0 3 0 ...
## $ SAKARYA : num 0 0 0 0 0 0 0 0 0 0 ...
## $ SAMSUN : num 1041 244 1550 1575 1979 ...
## $ SIIRT : num 0 0 0 0 0 0 0 0 0 0 ...
## $ SINOP : num 0 0 0 742 7 3 751 786 367 561 ...
## $ SIVAS : num 0 0 0 0 144 372 687 344 71 8 ...
## $ TEKIRDAG : num 1394 1598 1742 1754 2162 ...
## $ TOKAT : num 0 0 0 0 0 0 0 0 0 0 ...
## $ TRABZON : num 1128 1043 1100 1359 1637 ...
## $ TUNCELI : num 0 0 0 0 0 0 0 0 0 0 ...
## $ URFA : num 548 626 767 804 991 ...
## $ USAK : num 0 0 0 0 0 0 0 0 0 8 ...
## $ VAN : num 818 1235 2270 1472 1740 ...
## $ YOZGAT : num 0 0 0 0 0 0 0 0 0 0 ...
## $ ZONGULDAK : num 298 320 418 447 344 409 461 344 271 455 ...
## $ AKSARAY : num 0 0 0 0 0 0 0 0 0 0 ...
## $ BAYBURT : num 0 0 0 0 0 0 0 0 0 0 ...
## $ KARAMAN : num 0 0 0 0 0 0 0 0 0 0 ...
## $ KIRIKKALE : num 0 0 0 0 0 0 0 0 0 0 ...
## $ BATMAN : num 0 0 0 0 0 0 0 0 0 0 ...
## $ SIRNAK : num 6896 8242 10787 11411 11977 ...
## $ BARTIN : num 1 4 0 4 5 2 5 4 4 8 ...
## $ ARDAHAN : num 209 174 359 702 974 ...
## $ IGDIR : num 18666 19072 17850 19436 22071 ...
## $ YALOVA : num 0 0 0 0 0 0 0 0 0 0 ...
## $ KARABUK : num 0 0 0 0 0 0 0 0 0 0 ...
## $ KILIS : num 18005 13546 35232 28396 44467 ...
## $ OSMANIYE : num 0 0 0 0 0 0 0 0 0 0 ...
## $ DUZCE : num 0 0 0 0 0 0 0 0 0 0 ...
colSums(is.na(db_melt))
## Tarih variable value
## 0 0 5
names(db_melt)[names(db_melt) == "variable"] <- "City"
head(df)
This treemap chart shows that top 10 cities with the most tourists.
<- db_melt %>% na.omit(db_melt) %>% group_by(City) %>%
db_top10 summarise(total = sum(value)) %>%
slice_max(order_by = total, n = 10)
ggplot(db_top10, aes(area = total, fill = City,
label = paste(City, total, sep = "\n"))) +
geom_treemap() +
geom_treemap_text(colour = "white",
place = "centre",
size = 15) +
theme(legend.position = "none")
Distribution according to the border gates of the top 3 cities. A great decrease is observed in 2015 and 2016 due to the shooting down of Russian warplanes and terrorist attacks.
<- db_melt %>% mutate(Year = format(db_melt$Tarih, "%Y")) %>%
db_line group_by(Year, City) %>%
filter(City %in% c("ANTALYA", "ISTANBUL", "EDIRNE")) %>% #top 3 city
summarise(total = sum(value))
ggplot(db_line, aes(x=Year, y=total, group=City, color=City)) +
geom_line() + theme(axis.text.x = element_text(angle = 90)) +
scale_y_continuous(labels = function(l) {
paste0(round(l/1e6,1),"m")
})
Dataset showing Turkey’s tourism revenues and expenses between 2008 and 2021.
<- read_rds("https://raw.githubusercontent.com/pjournal/mef05g-r-u-mine/gh-pages/files/travel_incomes_expenses.rds")
trv
<- trv[-c(166,167), ]
trv <- trv[, 1:2]
trv1 $K1 <- NULL
trv1<- apply(trv[,2:14], FUN = decomma, MARGIN = 2)
trv2 = cbind(trv1,trv2)
trv_raw
str(trv_raw)
## 'data.frame': 165 obs. of 14 variables:
## $ Tarih: chr "2008-01-01" "2008-02-01" "2008-03-01" "2008-04-01" ...
## $ K1 : num 917 827 1128 1128 1837 ...
## $ K2 : num 5 2 3 1 3 4 5 5 2 4 ...
## $ K3 : num 1172736 1073986 1478744 1677867 2769178 ...
## $ K4 : num 782 770 762 672 663 667 786 800 799 764 ...
## $ K5 : num 642 597 851 879 1592 ...
## $ K6 : num 919539 858751 1221568 1411495 2509997 ...
## $ K7 : num 698 695 697 623 634 641 715 720 723 708 ...
## $ K8 : num 270 228 273 247 241 ...
## $ K9 : num 253197 215235 257176 266372 259181 ...
## $ K10 : num 1067 1062 1063 928 931 ...
## $ K11 : num 275 255 278 300 324 394 334 265 196 414 ...
## $ K12 : num 352491 338170 374133 427658 461661 ...
## $ K13 : num 781 755 743 703 701 695 764 759 746 924 ...
colSums(is.na(trv_raw))
## Tarih K1 K2 K3 K4 K5 K6 K7 K8 K9 K10 K11 K12
## 0 2 3 3 3 3 3 3 3 3 3 2 3
## K13
## 3
$Tarih <- as.Date(trv_raw$Tarih, format = "%Y-%m-%d")
trv_rawstr(trv_raw$Tarih)
## Date[1:165], format: "2008-01-01" "2008-02-01" "2008-03-01" "2008-04-01" "2008-05-01" ...
<- melt(trv_raw, id.vars = "Tarih")
trv_melt str(trv_melt)
## 'data.frame': 2145 obs. of 3 variables:
## $ Tarih : Date, format: "2008-01-01" "2008-02-01" ...
## $ variable: Factor w/ 13 levels "K1","K2","K3",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ value : num 917 827 1128 1128 1837 ...
colSums(is.na(trv_melt))
## Tarih variable value
## 0 0 37
The graph values depend on the criteria below, according to which a time-dependent plot was created. Due to the value loss of Turkish Lira since 2008, per capita expenditures have decreased in dollars too.
<- trv_melt %>% mutate(Year = format(trv_melt$Tarih, "%Y")) %>%
trv_k13 filter(trv_melt$variable %in% c("K13","K10", "K7")) %>%
group_by(Year, variable) %>%
summarise(total = sum(value,na.rm = TRUE))
ggplot(trv_k13, aes(x=Year, y=total, group=variable, color=variable)) +
geom_line() + theme(axis.text.x = element_text(angle = 90)) + geom_point()