#Executive summary For the final project, our main question was, what are the patterns between South Korean visitors in AGE, GENDER, and PURPOSE? From this dataset, we wanted to see why visitors visit South Korea, and we studied the data intensely from the three data. From AGE, we compared the most popular two months to see which age group visits South Korea the most. Next, in GENDER, we abstracted the data to the top five countries from Asia. We wanted to show from which country how many people from each gender visit South Korea the most. Lastly, for PURPOSE, we chose two reasons for people visiting South Korea: “studying” and “business.” We compared and saw which took a more significant part in people visiting South Korea.

Through all this data and graphs, we wanted to show people that visitors visit South Korea for many reasons. People usually know there are a lot of visitors from other countries who come to South Korea. But we don’t know what age group comes, which gender visits more, and for what purpose people see. To solve this curiosity, we used these three graphs to show it.

#Data Background The Korea Tourism Organization (KTO) has compiled, analyzed, and provided statistics on foreign and overseas tourists visiting Korea by type. Firstly, in the age file, the data is separated by the age of the visitors. Secondly, in the gender file, the data is divided by the gender of the visitors. Lastly, in the purpose file, the data is separated by the purpose of visitors. These three files have standard columns: date, nation, visitor, growth, and share.

#Data cleaning

library(ggplot2) # To create a variety of plots and charts.
library(tidyr) # For data tidying and reshaping, also cleaning and organizing the data.
library(dplyr) # Makes easy to use functions for filtering, summarizing, arranging, anf transforming data.
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(scales) # Using 'Sprintf' code from 'scales' package that allows for flexible formatting of character strings. We used to format the labels with both the category names (%s) and corresponding percentages (%.1f%%).

# Common Data Cleaning these type of data set
# Check for Missing Values, Remove Rows with Missing Values, Convert 'date' Column to Date Type, Convert Character Columns to Factors,
# Handle Outliers in the 'visitor' Column Using.

sum(is.na(data))
## Warning in is.na(data): is.na() applied to non-(list or vector) of type
## 'closure'
## [1] 0
data <- na.omit("Age-Age.csv")

data <- read.csv("Age-Age.csv")
data$date
##   [1] "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1" 
##   [8] "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1" 
##  [15] "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1" 
##  [22] "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1" 
##  [29] "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1" 
##  [36] "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1" 
##  [43] "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1" 
##  [50] "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-1" 
##  [57] "2019-1"  "2019-1"  "2019-1"  "2019-1"  "2019-2"  "2019-2"  "2019-2" 
##  [64] "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2" 
##  [71] "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2" 
##  [78] "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2" 
##  [85] "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2" 
##  [92] "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2" 
##  [99] "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2" 
## [106] "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2" 
## [113] "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2"  "2019-2" 
## [120] "2019-2"  "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3" 
## [127] "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3" 
## [134] "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3" 
## [141] "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3" 
## [148] "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3" 
## [155] "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3" 
## [162] "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3" 
## [169] "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3" 
## [176] "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-3"  "2019-4"  "2019-4" 
## [183] "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4" 
## [190] "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4" 
## [197] "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4" 
## [204] "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4" 
## [211] "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4" 
## [218] "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4" 
## [225] "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4" 
## [232] "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4"  "2019-4" 
## [239] "2019-4"  "2019-4"  "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5" 
## [246] "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5" 
## [253] "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5" 
## [260] "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5" 
## [267] "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5" 
## [274] "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5" 
## [281] "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5" 
## [288] "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5" 
## [295] "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-5"  "2019-6" 
## [302] "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6" 
## [309] "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6" 
## [316] "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6" 
## [323] "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6" 
## [330] "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6" 
## [337] "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6" 
## [344] "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6" 
## [351] "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6"  "2019-6" 
## [358] "2019-6"  "2019-6"  "2019-6"  "2019-7"  "2019-7"  "2019-7"  "2019-7" 
## [365] "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7" 
## [372] "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7" 
## [379] "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7" 
## [386] "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7" 
## [393] "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7" 
## [400] "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7" 
## [407] "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7" 
## [414] "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7"  "2019-7" 
## [421] "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8" 
## [428] "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8" 
## [435] "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8" 
## [442] "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8" 
## [449] "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8" 
## [456] "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8" 
## [463] "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8" 
## [470] "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-8" 
## [477] "2019-8"  "2019-8"  "2019-8"  "2019-8"  "2019-9"  "2019-9"  "2019-9" 
## [484] "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9" 
## [491] "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9" 
## [498] "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9" 
## [505] "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9" 
## [512] "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9" 
## [519] "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9" 
## [526] "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9" 
## [533] "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9"  "2019-9" 
## [540] "2019-9"  "2019-10" "2019-10" "2019-10" "2019-10" "2019-10" "2019-10"
## [547] "2019-10" "2019-10" "2019-10" "2019-10" "2019-10" "2019-10" "2019-10"
## [554] "2019-10" "2019-10" "2019-10" "2019-10" "2019-10" "2019-10" "2019-10"
## [561] "2019-10" "2019-10" "2019-10" "2019-10" "2019-10" "2019-10" "2019-10"
## [568] "2019-10" "2019-10" "2019-10" "2019-10" "2019-10" "2019-10" "2019-10"
## [575] "2019-10" "2019-10" "2019-10" "2019-10" "2019-10" "2019-10" "2019-10"
## [582] "2019-10" "2019-10" "2019-10" "2019-10" "2019-10" "2019-10" "2019-10"
## [589] "2019-10" "2019-10" "2019-10" "2019-10" "2019-10" "2019-10" "2019-10"
## [596] "2019-10" "2019-10" "2019-10" "2019-10" "2019-10" "2019-11" "2019-11"
## [603] "2019-11" "2019-11" "2019-11" "2019-11" "2019-11" "2019-11" "2019-11"
## [610] "2019-11" "2019-11" "2019-11" "2019-11" "2019-11" "2019-11" "2019-11"
## [617] "2019-11" "2019-11" "2019-11" "2019-11" "2019-11" "2019-11" "2019-11"
## [624] "2019-11" "2019-11" "2019-11" "2019-11" "2019-11" "2019-11" "2019-11"
## [631] "2019-11" "2019-11" "2019-11" "2019-11" "2019-11" "2019-11" "2019-11"
## [638] "2019-11" "2019-11" "2019-11" "2019-11" "2019-11" "2019-11" "2019-11"
## [645] "2019-11" "2019-11" "2019-11" "2019-11" "2019-11" "2019-11" "2019-11"
## [652] "2019-11" "2019-11" "2019-11" "2019-11" "2019-11" "2019-11" "2019-11"
## [659] "2019-11" "2019-11" "2019-12" "2019-12" "2019-12" "2019-12" "2019-12"
## [666] "2019-12" "2019-12" "2019-12" "2019-12" "2019-12" "2019-12" "2019-12"
## [673] "2019-12" "2019-12" "2019-12" "2019-12" "2019-12" "2019-12" "2019-12"
## [680] "2019-12" "2019-12" "2019-12" "2019-12" "2019-12" "2019-12" "2019-12"
## [687] "2019-12" "2019-12" "2019-12" "2019-12" "2019-12" "2019-12" "2019-12"
## [694] "2019-12" "2019-12" "2019-12" "2019-12" "2019-12" "2019-12" "2019-12"
## [701] "2019-12" "2019-12" "2019-12" "2019-12" "2019-12" "2019-12" "2019-12"
## [708] "2019-12" "2019-12" "2019-12" "2019-12" "2019-12" "2019-12" "2019-12"
## [715] "2019-12" "2019-12" "2019-12" "2019-12" "2019-12" "2019-12" "2020-1" 
## [722] "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1" 
## [729] "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1" 
## [736] "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1" 
## [743] "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1" 
## [750] "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1" 
## [757] "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1" 
## [764] "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1" 
## [771] "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1"  "2020-1" 
## [778] "2020-1"  "2020-1"  "2020-1"  "2020-2"  "2020-2"  "2020-2"  "2020-2" 
## [785] "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2" 
## [792] "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2" 
## [799] "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2" 
## [806] "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2" 
## [813] "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2" 
## [820] "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2" 
## [827] "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2" 
## [834] "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2"  "2020-2" 
## [841] "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3" 
## [848] "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3" 
## [855] "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3" 
## [862] "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3" 
## [869] "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3" 
## [876] "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3" 
## [883] "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3" 
## [890] "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-3" 
## [897] "2020-3"  "2020-3"  "2020-3"  "2020-3"  "2020-4"  "2020-4"  "2020-4" 
## [904] "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4" 
## [911] "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4" 
## [918] "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4" 
## [925] "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4" 
## [932] "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4" 
## [939] "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4" 
## [946] "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4" 
## [953] "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4"  "2020-4" 
## [960] "2020-4"
data <- read.csv("Age-Age.csv")
data$nation
##   [1] "China"           "Japan"           "Taiwan"          "Hong Kong"      
##   [5] "Macao"           "Phillipines"     "Indonesia"       "Thailand"       
##   [9] "Vietnam"         "India"           "Malaysia"        "Singapore"      
##  [13] "Mongolia"        "Uzbekistan"      "Myanmar"         "*GCC"           
##  [17] "Kazakhstan"      "Turkey"          "Cambodia"        "Sri Lanka"      
##  [21] "Bangladesh"      "Pakistan"        "Israel"          "Iran"           
##  [25] "Asia others"     "USA"             "Canada"          "Brazil"         
##  [29] "Mexico"          "America others"  "Russia"          "UK"             
##  [33] "Germany"         "France"          "Italy"           "Netherland"     
##  [37] "Ukraine"         "Spain"           "Romania"         "Norway"         
##  [41] "Sweden"          "Poland"          "Swiss"           "Portugal"       
##  [45] "Austria"         "Finland"         "Belgium"         "Croatia"        
##  [49] "Greece"          "Bulgaria"        "Denmark"         "Ireland"        
##  [53] "Europe others"   "Austrailia"      "New Zealand"     "Oceania others" 
##  [57] "South Africa"    "Africa others"   "Stateless"       "Overseas Korean"
##  [61] "China"           "Japan"           "Taiwan"          "Hong Kong"      
##  [65] "Macao"           "Phillipines"     "Indonesia"       "Thailand"       
##  [69] "Vietnam"         "India"           "Malaysia"        "Singapore"      
##  [73] "Mongolia"        "Uzbekistan"      "Myanmar"         "*GCC"           
##  [77] "Kazakhstan"      "Turkey"          "Cambodia"        "Sri Lanka"      
##  [81] "Bangladesh"      "Pakistan"        "Israel"          "Iran"           
##  [85] "Asia others"     "USA"             "Canada"          "Brazil"         
##  [89] "Mexico"          "America others"  "Russia"          "UK"             
##  [93] "Germany"         "France"          "Italy"           "Netherland"     
##  [97] "Ukraine"         "Spain"           "Romania"         "Norway"         
## [101] "Sweden"          "Poland"          "Swiss"           "Portugal"       
## [105] "Austria"         "Finland"         "Belgium"         "Croatia"        
## [109] "Greece"          "Bulgaria"        "Denmark"         "Ireland"        
## [113] "Europe others"   "Austrailia"      "New Zealand"     "Oceania others" 
## [117] "South Africa"    "Africa others"   "Stateless"       "Overseas Korean"
## [121] "China"           "Japan"           "Taiwan"          "Hong Kong"      
## [125] "Macao"           "Phillipines"     "Indonesia"       "Thailand"       
## [129] "Vietnam"         "India"           "Malaysia"        "Singapore"      
## [133] "Mongolia"        "Uzbekistan"      "Myanmar"         "*GCC"           
## [137] "Kazakhstan"      "Turkey"          "Cambodia"        "Sri Lanka"      
## [141] "Bangladesh"      "Pakistan"        "Israel"          "Iran"           
## [145] "Asia others"     "USA"             "Canada"          "Brazil"         
## [149] "Mexico"          "America others"  "Russia"          "UK"             
## [153] "Germany"         "France"          "Italy"           "Netherland"     
## [157] "Ukraine"         "Spain"           "Romania"         "Norway"         
## [161] "Sweden"          "Poland"          "Swiss"           "Portugal"       
## [165] "Austria"         "Finland"         "Belgium"         "Croatia"        
## [169] "Greece"          "Bulgaria"        "Denmark"         "Ireland"        
## [173] "Europe others"   "Austrailia"      "New Zealand"     "Oceania others" 
## [177] "South Africa"    "Africa others"   "Stateless"       "Overseas Korean"
## [181] "China"           "Japan"           "Taiwan"          "Hong Kong"      
## [185] "Macao"           "Phillipines"     "Indonesia"       "Thailand"       
## [189] "Vietnam"         "India"           "Malaysia"        "Singapore"      
## [193] "Mongolia"        "Uzbekistan"      "Myanmar"         "*GCC"           
## [197] "Kazakhstan"      "Turkey"          "Cambodia"        "Sri Lanka"      
## [201] "Bangladesh"      "Pakistan"        "Israel"          "Iran"           
## [205] "Asia others"     "USA"             "Canada"          "Brazil"         
## [209] "Mexico"          "America others"  "Russia"          "UK"             
## [213] "Germany"         "France"          "Italy"           "Netherland"     
## [217] "Ukraine"         "Spain"           "Romania"         "Norway"         
## [221] "Sweden"          "Poland"          "Swiss"           "Portugal"       
## [225] "Austria"         "Finland"         "Belgium"         "Croatia"        
## [229] "Greece"          "Bulgaria"        "Denmark"         "Ireland"        
## [233] "Europe others"   "Austrailia"      "New Zealand"     "Oceania others" 
## [237] "South Africa"    "Africa others"   "Stateless"       "Overseas Korean"
## [241] "China"           "Japan"           "Taiwan"          "Hong Kong"      
## [245] "Macao"           "Phillipines"     "Indonesia"       "Thailand"       
## [249] "Vietnam"         "India"           "Malaysia"        "Singapore"      
## [253] "Mongolia"        "Uzbekistan"      "Myanmar"         "*GCC"           
## [257] "Kazakhstan"      "Turkey"          "Cambodia"        "Sri Lanka"      
## [261] "Bangladesh"      "Pakistan"        "Israel"          "Iran"           
## [265] "Asia others"     "USA"             "Canada"          "Brazil"         
## [269] "Mexico"          "America others"  "Russia"          "UK"             
## [273] "Germany"         "France"          "Italy"           "Netherland"     
## [277] "Ukraine"         "Spain"           "Romania"         "Norway"         
## [281] "Sweden"          "Poland"          "Swiss"           "Portugal"       
## [285] "Austria"         "Finland"         "Belgium"         "Croatia"        
## [289] "Greece"          "Bulgaria"        "Denmark"         "Ireland"        
## [293] "Europe others"   "Austrailia"      "New Zealand"     "Oceania others" 
## [297] "South Africa"    "Africa others"   "Stateless"       "Overseas Korean"
## [301] "China"           "Japan"           "Taiwan"          "Hong Kong"      
## [305] "Macao"           "Phillipines"     "Indonesia"       "Thailand"       
## [309] "Vietnam"         "India"           "Malaysia"        "Singapore"      
## [313] "Mongolia"        "Uzbekistan"      "Myanmar"         "*GCC"           
## [317] "Kazakhstan"      "Turkey"          "Cambodia"        "Sri Lanka"      
## [321] "Bangladesh"      "Pakistan"        "Israel"          "Iran"           
## [325] "Asia others"     "USA"             "Canada"          "Brazil"         
## [329] "Mexico"          "America others"  "Russia"          "UK"             
## [333] "Germany"         "France"          "Italy"           "Netherland"     
## [337] "Ukraine"         "Spain"           "Romania"         "Norway"         
## [341] "Sweden"          "Poland"          "Swiss"           "Portugal"       
## [345] "Austria"         "Finland"         "Belgium"         "Croatia"        
## [349] "Greece"          "Bulgaria"        "Denmark"         "Ireland"        
## [353] "Europe others"   "Austrailia"      "New Zealand"     "Oceania others" 
## [357] "South Africa"    "Africa others"   "Stateless"       "Overseas Korean"
## [361] "China"           "Japan"           "Taiwan"          "Hong Kong"      
## [365] "Macao"           "Phillipines"     "Indonesia"       "Thailand"       
## [369] "Vietnam"         "India"           "Malaysia"        "Singapore"      
## [373] "Mongolia"        "Uzbekistan"      "Myanmar"         "*GCC"           
## [377] "Kazakhstan"      "Turkey"          "Cambodia"        "Sri Lanka"      
## [381] "Bangladesh"      "Pakistan"        "Israel"          "Iran"           
## [385] "Asia others"     "USA"             "Canada"          "Brazil"         
## [389] "Mexico"          "America others"  "Russia"          "UK"             
## [393] "Germany"         "France"          "Italy"           "Netherland"     
## [397] "Ukraine"         "Spain"           "Romania"         "Norway"         
## [401] "Sweden"          "Poland"          "Swiss"           "Portugal"       
## [405] "Austria"         "Finland"         "Belgium"         "Croatia"        
## [409] "Greece"          "Bulgaria"        "Denmark"         "Ireland"        
## [413] "Europe others"   "Austrailia"      "New Zealand"     "Oceania others" 
## [417] "South Africa"    "Africa others"   "Stateless"       "Overseas Korean"
## [421] "China"           "Japan"           "Taiwan"          "Hong Kong"      
## [425] "Macao"           "Phillipines"     "Indonesia"       "Thailand"       
## [429] "Vietnam"         "India"           "Malaysia"        "Singapore"      
## [433] "Mongolia"        "Uzbekistan"      "Myanmar"         "*GCC"           
## [437] "Kazakhstan"      "Turkey"          "Cambodia"        "Sri Lanka"      
## [441] "Bangladesh"      "Pakistan"        "Israel"          "Iran"           
## [445] "Asia others"     "USA"             "Canada"          "Brazil"         
## [449] "Mexico"          "America others"  "Russia"          "UK"             
## [453] "Germany"         "France"          "Italy"           "Netherland"     
## [457] "Ukraine"         "Spain"           "Romania"         "Norway"         
## [461] "Sweden"          "Poland"          "Swiss"           "Portugal"       
## [465] "Austria"         "Finland"         "Belgium"         "Croatia"        
## [469] "Greece"          "Bulgaria"        "Denmark"         "Ireland"        
## [473] "Europe others"   "Austrailia"      "New Zealand"     "Oceania others" 
## [477] "South Africa"    "Africa others"   "Stateless"       "Overseas Korean"
## [481] "China"           "Japan"           "Taiwan"          "Hong Kong"      
## [485] "Macao"           "Phillipines"     "Indonesia"       "Thailand"       
## [489] "Vietnam"         "India"           "Malaysia"        "Singapore"      
## [493] "Mongolia"        "Uzbekistan"      "Myanmar"         "*GCC"           
## [497] "Kazakhstan"      "Turkey"          "Cambodia"        "Sri Lanka"      
## [501] "Bangladesh"      "Pakistan"        "Israel"          "Iran"           
## [505] "Asia others"     "USA"             "Canada"          "Brazil"         
## [509] "Mexico"          "America others"  "Russia"          "UK"             
## [513] "Germany"         "France"          "Italy"           "Netherland"     
## [517] "Ukraine"         "Spain"           "Romania"         "Norway"         
## [521] "Sweden"          "Poland"          "Swiss"           "Portugal"       
## [525] "Austria"         "Finland"         "Belgium"         "Croatia"        
## [529] "Greece"          "Bulgaria"        "Denmark"         "Ireland"        
## [533] "Europe others"   "Austrailia"      "New Zealand"     "Oceania others" 
## [537] "South Africa"    "Africa others"   "Stateless"       "Overseas Korean"
## [541] "China"           "Japan"           "Taiwan"          "Hong Kong"      
## [545] "Macao"           "Phillipines"     "Indonesia"       "Thailand"       
## [549] "Vietnam"         "India"           "Malaysia"        "Singapore"      
## [553] "Mongolia"        "Uzbekistan"      "Myanmar"         "*GCC"           
## [557] "Kazakhstan"      "Turkey"          "Cambodia"        "Sri Lanka"      
## [561] "Bangladesh"      "Pakistan"        "Israel"          "Iran"           
## [565] "Asia others"     "USA"             "Canada"          "Brazil"         
## [569] "Mexico"          "America others"  "Russia"          "UK"             
## [573] "Germany"         "France"          "Italy"           "Netherland"     
## [577] "Ukraine"         "Spain"           "Romania"         "Norway"         
## [581] "Sweden"          "Poland"          "Swiss"           "Portugal"       
## [585] "Austria"         "Finland"         "Belgium"         "Croatia"        
## [589] "Greece"          "Bulgaria"        "Denmark"         "Ireland"        
## [593] "Europe others"   "Austrailia"      "New Zealand"     "Oceania others" 
## [597] "South Africa"    "Africa others"   "Stateless"       "Overseas Korean"
## [601] "China"           "Japan"           "Taiwan"          "Hong Kong"      
## [605] "Macao"           "Phillipines"     "Indonesia"       "Thailand"       
## [609] "Vietnam"         "India"           "Malaysia"        "Singapore"      
## [613] "Mongolia"        "Uzbekistan"      "Myanmar"         "*GCC"           
## [617] "Kazakhstan"      "Turkey"          "Cambodia"        "Sri Lanka"      
## [621] "Bangladesh"      "Pakistan"        "Israel"          "Iran"           
## [625] "Asia others"     "USA"             "Canada"          "Brazil"         
## [629] "Mexico"          "America others"  "Russia"          "UK"             
## [633] "Germany"         "France"          "Italy"           "Netherland"     
## [637] "Ukraine"         "Spain"           "Romania"         "Norway"         
## [641] "Sweden"          "Poland"          "Swiss"           "Portugal"       
## [645] "Austria"         "Finland"         "Belgium"         "Croatia"        
## [649] "Greece"          "Bulgaria"        "Denmark"         "Ireland"        
## [653] "Europe others"   "Austrailia"      "New Zealand"     "Oceania others" 
## [657] "South Africa"    "Africa others"   "Stateless"       "Overseas Korean"
## [661] "China"           "Japan"           "Taiwan"          "Hong Kong"      
## [665] "Macao"           "Phillipines"     "Indonesia"       "Thailand"       
## [669] "Vietnam"         "India"           "Malaysia"        "Singapore"      
## [673] "Mongolia"        "Uzbekistan"      "Myanmar"         "*GCC"           
## [677] "Kazakhstan"      "Turkey"          "Cambodia"        "Sri Lanka"      
## [681] "Bangladesh"      "Pakistan"        "Israel"          "Iran"           
## [685] "Asia others"     "USA"             "Canada"          "Brazil"         
## [689] "Mexico"          "America others"  "Russia"          "UK"             
## [693] "Germany"         "France"          "Italy"           "Netherland"     
## [697] "Ukraine"         "Spain"           "Romania"         "Norway"         
## [701] "Sweden"          "Poland"          "Swiss"           "Portugal"       
## [705] "Austria"         "Finland"         "Belgium"         "Croatia"        
## [709] "Greece"          "Bulgaria"        "Denmark"         "Ireland"        
## [713] "Europe others"   "Austrailia"      "New Zealand"     "Oceania others" 
## [717] "South Africa"    "Africa others"   "Stateless"       "Overseas Korean"
## [721] "China"           "Japan"           "Taiwan"          "Hong Kong"      
## [725] "Macao"           "Phillipines"     "Indonesia"       "Thailand"       
## [729] "Vietnam"         "India"           "Malaysia"        "Singapore"      
## [733] "Mongolia"        "Uzbekistan"      "Myanmar"         "*GCC"           
## [737] "Kazakhstan"      "Turkey"          "Cambodia"        "Sri Lanka"      
## [741] "Bangladesh"      "Pakistan"        "Israel"          "Iran"           
## [745] "Asia others"     "USA"             "Canada"          "Brazil"         
## [749] "Mexico"          "America others"  "Russia"          "UK"             
## [753] "Germany"         "France"          "Italy"           "Netherland"     
## [757] "Ukraine"         "Spain"           "Romania"         "Norway"         
## [761] "Sweden"          "Poland"          "Swiss"           "Portugal"       
## [765] "Austria"         "Finland"         "Belgium"         "Croatia"        
## [769] "Greece"          "Bulgaria"        "Denmark"         "Ireland"        
## [773] "Europe others"   "Austrailia"      "New Zealand"     "Oceania others" 
## [777] "South Africa"    "Africa others"   "Stateless"       "Overseas Korean"
## [781] "China"           "Japan"           "Taiwan"          "Hong Kong"      
## [785] "Macao"           "Phillipines"     "Indonesia"       "Thailand"       
## [789] "Vietnam"         "India"           "Malaysia"        "Singapore"      
## [793] "Mongolia"        "Uzbekistan"      "Myanmar"         "*GCC"           
## [797] "Kazakhstan"      "Turkey"          "Cambodia"        "Sri Lanka"      
## [801] "Bangladesh"      "Pakistan"        "Israel"          "Iran"           
## [805] "Asia others"     "USA"             "Canada"          "Brazil"         
## [809] "Mexico"          "America others"  "Russia"          "UK"             
## [813] "Germany"         "France"          "Italy"           "Netherland"     
## [817] "Ukraine"         "Spain"           "Romania"         "Norway"         
## [821] "Sweden"          "Poland"          "Swiss"           "Portugal"       
## [825] "Austria"         "Finland"         "Belgium"         "Croatia"        
## [829] "Greece"          "Bulgaria"        "Denmark"         "Ireland"        
## [833] "Europe others"   "Austrailia"      "New Zealand"     "Oceania others" 
## [837] "South Africa"    "Africa others"   "Stateless"       "Overseas Korean"
## [841] "China"           "Japan"           "Taiwan"          "Hong Kong"      
## [845] "Macao"           "Phillipines"     "Indonesia"       "Thailand"       
## [849] "Vietnam"         "India"           "Malaysia"        "Singapore"      
## [853] "Mongolia"        "Uzbekistan"      "Myanmar"         "*GCC"           
## [857] "Kazakhstan"      "Turkey"          "Cambodia"        "Sri Lanka"      
## [861] "Bangladesh"      "Pakistan"        "Israel"          "Iran"           
## [865] "Asia others"     "USA"             "Canada"          "Brazil"         
## [869] "Mexico"          "America others"  "Russia"          "UK"             
## [873] "Germany"         "France"          "Italy"           "Netherland"     
## [877] "Ukraine"         "Spain"           "Romania"         "Norway"         
## [881] "Sweden"          "Poland"          "Swiss"           "Portugal"       
## [885] "Austria"         "Finland"         "Belgium"         "Croatia"        
## [889] "Greece"          "Bulgaria"        "Denmark"         "Ireland"        
## [893] "Europe others"   "Austrailia"      "New Zealand"     "Oceania others" 
## [897] "South Africa"    "Africa others"   "Stateless"       "Overseas Korean"
## [901] "China"           "Japan"           "Taiwan"          "Hong Kong"      
## [905] "Macao"           "Phillipines"     "Indonesia"       "Thailand"       
## [909] "Vietnam"         "India"           "Malaysia"        "Singapore"      
## [913] "Mongolia"        "Uzbekistan"      "Myanmar"         "*GCC"           
## [917] "Kazakhstan"      "Turkey"          "Cambodia"        "Sri Lanka"      
## [921] "Bangladesh"      "Pakistan"        "Israel"          "Iran"           
## [925] "Asia others"     "USA"             "Canada"          "Brazil"         
## [929] "Mexico"          "America others"  "Russia"          "UK"             
## [933] "Germany"         "France"          "Italy"           "Netherland"     
## [937] "Ukraine"         "Spain"           "Romania"         "Norway"         
## [941] "Sweden"          "Poland"          "Swiss"           "Portugal"       
## [945] "Austria"         "Finland"         "Belgium"         "Croatia"        
## [949] "Greece"          "Bulgaria"        "Denmark"         "Ireland"        
## [953] "Europe others"   "Austrailia"      "New Zealand"     "Oceania others" 
## [957] "South Africa"    "Africa others"   "Stateless"       "Overseas Korean"
Q1 <- quantile(data$visitor, 0.25)
Q3 <- quantile(data$visitor, 0.75)
IQR_value <- Q3 - Q1
data <- data[!(data$visitor < (Q1 - 1.5 * IQR_value) | data$visitor > (Q3 + 1.5 * IQR_value)), ]

data <- read.csv("Age-Age.csv")
data <- read.csv("Gender.csv")
data <- read.csv("Purpose-Enter_korea_by_purpose.csv")

#Individual Figures:

#Figure 1 (At which season people visit Korea the most?)

library(ggplot2)
library(tidyr)
library(dplyr)

data <- read.csv("Age-Age.csv")

data[, c("age0.20", "age21.30", "age31.40", "age41.50", "age51.60", "age61")] <- 
  lapply(data[, c("age0.20", "age21.30", "age31.40", "age41.50", "age51.60", "age61")], as.numeric)

data_2019_12 <- subset(data, date == "2019-12")

total_age_0_20 <- sum(data_2019_12$age0.20)
total_age_21_30 <- sum(data_2019_12$age21.30)
total_age_31_40 <- sum(data_2019_12$age31.40)
total_age_41_50 <- sum(data_2019_12$age41.50)
total_age_51_60 <- sum(data_2019_12$age51.60)
total_age_61 <- sum(data_2019_12$age61)

total_values <- c(total_age_0_20, total_age_21_30, total_age_31_40, total_age_41_50, total_age_51_60, total_age_61)

options(scipen = 999)
barplot(total_values, 
        names.arg = c("0-20", "21-30", "31-40", "41-50", "51-60", "61+"),
        main = "Total Number of Visitors in Each Age Group (2019-12)",
        xlab = "Age Group",
        ylab = "Total Number of Visitors",
        col = "yellow",
        ylim = c(0, max(total_values) * 1.2))

data <- read.csv("Age-Age.csv")

data[, c("age0.20", "age21.30", "age31.40", "age41.50", "age51.60", "age61")] <- 
  lapply(data[, c("age0.20", "age21.30", "age31.40", "age41.50", "age51.60", "age61")], as.numeric)

data_2019_7 <- subset(data, date == "2019-7")

total_age_0_20 <- sum(data_2019_7$age0.20)
total_age_21_30 <- sum(data_2019_7$age21.30)
total_age_31_40 <- sum(data_2019_7$age31.40)
total_age_41_50 <- sum(data_2019_7$age41.50)
total_age_51_60 <- sum(data_2019_7$age51.60)
total_age_61 <- sum(data_2019_7$age61)

total_values <- c(total_age_0_20, total_age_21_30, total_age_31_40, total_age_41_50, total_age_51_60, total_age_61)

options(scipen = 999)
barplot(total_values, 
        names.arg = c("0-20", "21-30", "31-40", "41-50", "51-60", "61+"),
        main = "Total Number of Visitors in Each Age Group (2019-7)",
        xlab = "Age Group",
        ylab = "Total Number of Visitors",
        col = "green",
        ylim = c(0, max(total_values) * 1.2))

#Figure 2 (From Asia, which gender are most likely to visit South Korea?)

data <- read.csv("Gender.csv")
data <- read.csv("Gender.csv")
selected_countries <- c("Phillipines", "China", "Japan", "Macao", "Taiwan")
selected_data <- data[data$nation %in% selected_countries, c("nation", "male", "female")]

print(selected_data)
##          nation   male female
## 1         China 147511 231722
## 2         Japan  75070 129029
## 3        Taiwan  30805  56202
## 5         Macao    748   1787
## 6   Phillipines  10460   7295
## 61        China 191410 251668
## 62        Japan  70961 139997
## 63       Taiwan  34304  59456
## 65        Macao   1478   2451
## 66  Phillipines   9935   7822
## 121       China 189613 285340
## 122       Japan 106174 266368
## 123      Taiwan  29719  67812
## 125       Macao    819   2205
## 126 Phillipines  11556  11860
## 181       China 180816 298870
## 182       Japan 106567 180586
## 183      Taiwan  35445  76609
## 185       Macao   1226   3084
## 186 Phillipines  19859  26419
## 241       China 187922 297661
## 242       Japan 104270 179372
## 243      Taiwan  32707  68065
## 245       Macao    758   2150
## 246 Phillipines  14645  16538
## 301       China 169793 292378
## 302       Japan  98280 181523
## 303      Taiwan  37622  79905
## 305       Macao    982   2640
## 306 Phillipines  12415  12639
## 361       China 186367 319475
## 362       Japan  95905 176508
## 363      Taiwan  39999  72875
## 365       Macao   1705   3541
## 366 Phillipines   8468   7083
## 421       China 216737 345329
## 422       Japan 113714 212982
## 423      Taiwan  37471  70789
## 425       Macao   2174   4146
## 426 Phillipines   9660   7105
## 481       China 198669 330432
## 482       Japan  89993 158395
## 483      Taiwan  33054  68711
## 485       Macao    768   1959
## 486 Phillipines  11026  10400
## 541       China 204531 348980
## 542       Japan  86539 159473
## 543      Taiwan  38540  88437
## 545       Macao   1170   3333
## 546 Phillipines  16190  22844
## 601       China 183200 310161
## 602       Japan  88718 167326
## 603      Taiwan  30560  70670
## 605       Macao   1330   3566
## 606 Phillipines  12686  15764
## 661       China 179833 315451
## 662       Japan  89354 163795
## 663      Taiwan  28975  60622
## 665       Macao   2860   5481
## 666 Phillipines  14717  15378
## 721       China 179530 289862
## 722       Japan  71921 129621
## 723      Taiwan  41404  68152
## 725       Macao   2038   3309
## 726 Phillipines  10881   8348
## 781       China  52686  48043
## 782       Japan  67646 141475
## 783      Taiwan  18859  33722
## 785       Macao    184    317
## 786 Phillipines   8351   5958
## 841       China   7734   8300
## 842       Japan   3079   4943
## 843      Taiwan    152    325
## 845       Macao      5     11
## 846 Phillipines   2325    372
## 901       China   2238   1621
## 902       Japan    165    155
## 903      Taiwan     52     53
## 905       Macao      1      0
## 906 Phillipines    492     36
data <- read.csv("Gender.csv")
selected_countries <- c("Phillipines", "China", "Japan", "Macao", "Taiwan")
selected_data <- data[data$nation %in% selected_countries, c("nation", "male", "female")]
totals <- aggregate(cbind(male, female) ~ nation, data = selected_data, sum)

print(totals)
##        nation    male  female
## 1       China 2478590 3975293
## 2       Japan 1268356 2391548
## 3       Macao   18246   39980
## 4 Phillipines  173666  175861
## 5      Taiwan  469668  942405
unique_countries <- unique(totals$nation)
print(unique_countries)
## [1] "China"       "Japan"       "Macao"       "Phillipines" "Taiwan"
print(head(totals))
##        nation    male  female
## 1       China 2478590 3975293
## 2       Japan 1268356 2391548
## 3       Macao   18246   39980
## 4 Phillipines  173666  175861
## 5      Taiwan  469668  942405
library(ggplot2)

scatterplot <- ggplot(totals, aes(x = male, y = female, color = nation)) +
  geom_point() +
  labs(title = "Scatterplot of Male and Female by Country",
       x = "Male Count",
       y = "Female Count",
       color = "Country") +
  theme_minimal()

print(scatterplot)

#Figure 3 (Do people visit South Korea for studying or business more?)

data <- read.csv("Purpose-Enter_korea_by_purpose.csv")
data <- read.csv("Purpose-Enter_korea_by_purpose.csv")
selected_data <- data[, c("studying", "business")]

print(selected_data)
##     studying business
## 1       8793     2993
## 2        785     2233
## 3        180       74
## 4         90       59
## 5         17        2
## 6        184      211
## 7        187      136
## 8         96       37
## 9       1667      763
## 10       177     2656
## 11        99       95
## 12        48       94
## 13       484       77
## 14       407      561
## 15        67       10
## 16        72       37
## 17        92       24
## 18        36       13
## 19        51       39
## 20        28       54
## 21        97      126
## 22       193      178
## 23         9       12
## 24        23       45
## 25       205      308
## 26       229      418
## 27        43       57
## 28        41       16
## 29        38       11
## 30       128       24
## 31       191      181
## 32        41      175
## 33       177      278
## 34       288      297
## 35        40       83
## 36        77       47
## 37        28       58
## 38        52       36
## 39         3        8
## 40        28       66
## 41        18       29
## 42        27       10
## 43        19       18
## 44        13       14
## 45        13        8
## 46        18       23
## 47        22       24
## 48         3       12
## 49         0       17
## 50        10        1
## 51        16       21
## 52         2       15
## 53        91       44
## 54        34       93
## 55         5       20
## 56         0        3
## 57         6        9
## 58       206      718
## 59         1        4
## 60         0        0
## 61     38731     2694
## 62      2084     2125
## 63       908      105
## 64       489       54
## 65        33        1
## 66       189      171
## 67       697      147
## 68       332       56
## 69      9324      806
## 70       360     2303
## 71       604      136
## 72       257      114
## 73      1152      109
## 74      1217      716
## 75       231       13
## 76       192       27
## 77       404       21
## 78       151       13
## 79       147       53
## 80        48       52
## 81       265       83
## 82       463      290
## 83        14       15
## 84        64       67
## 85       537      383
## 86      1144      386
## 87       116       45
## 88       101       12
## 89       207        1
## 90       257       19
## 91       391      139
## 92       105      150
## 93       525      258
## 94       958      235
## 95       125       52
## 96       180       33
## 97        57       51
## 98       129       17
## 99        30        4
## 100       45       38
## 101       91       19
## 102       74       14
## 103       67       17
## 104       19        5
## 105       36        9
## 106      139       10
## 107       41       16
## 108       11        7
## 109        5       27
## 110       15        0
## 111       77       12
## 112       14        7
## 113      245       24
## 114      119       73
## 115       11       14
## 116        2        0
## 117        8        6
## 118      520      806
## 119        3        1
## 120        0        0
## 121    32532     3933
## 122     1231     2108
## 123      460       64
## 124      265       61
## 125       41        2
## 126      108      166
## 127      277      242
## 128      136       66
## 129     5394     1047
## 130      197     3283
## 131      286      107
## 132       49      161
## 133      967      119
## 134      863      896
## 135      102       17
## 136      135       22
## 137      178       11
## 138       38       15
## 139       38       43
## 140       28       53
## 141      230      148
## 142      256      233
## 143        1       11
## 144       30       95
## 145      402      547
## 146      190      400
## 147       37       42
## 148       21       19
## 149       18        7
## 150       79       22
## 151      182      141
## 152       50      126
## 153      106      219
## 154      245      274
## 155       33       64
## 156       20       47
## 157       17       95
## 158       36       21
## 159        2        5
## 160       24       37
## 161       47       30
## 162       21        8
## 163       21       13
## 164        8        2
## 165        5        9
## 166       15       17
## 167        9       16
## 168        3       11
## 169        1       13
## 170        3        3
## 171       10       11
## 172        5        7
## 173       67       31
## 174       13       99
## 175        2       24
## 176        2        2
## 177        6        5
## 178      259      831
## 179        0        2
## 180        0        0
## 181     9959     3575
## 182      333     1584
## 183      147       73
## 184       90       47
## 185        3        1
## 186       45      228
## 187       54      225
## 188       55       53
## 189     1284     1271
## 190       75     3039
## 191       27      120
## 192       19      116
## 193      248       83
## 194      109      651
## 195       17       13
## 196       34       24
## 197       17       20
## 198       13       12
## 199       18       63
## 200        8       72
## 201       49      137
## 202       66      315
## 203        2       11
## 204       12       79
## 205       64      484
## 206      113      352
## 207       15       44
## 208        5       15
## 209       15        7
## 210       19       34
## 211       41      166
## 212       18      141
## 213       84      212
## 214      164      224
## 215       12       46
## 216       12       48
## 217        8       76
## 218       29       20
## 219        1        6
## 220        8       29
## 221       22       18
## 222       11        9
## 223       11       15
## 224        2        5
## 225        9        9
## 226       27        8
## 227        8       20
## 228        1        7
## 229        0       15
## 230        2        4
## 231       14       16
## 232        1        4
## 233       24       54
## 234       13       77
## 235        2       19
## 236       13        3
## 237        1        7
## 238       70      786
## 239        0        2
## 240        0        0
## 241    14003     4034
## 242      715     2019
## 243      234       84
## 244      147       56
## 245       13        1
## 246       56      201
## 247       75      154
## 248       71       61
## 249     2338     1073
## 250       92     2896
## 251       57      116
## 252       71      152
## 253      390       95
## 254      152      830
## 255       33       17
## 256       51       21
## 257       38       15
## 258       45       12
## 259       22       44
## 260        7       64
## 261       30      102
## 262       62      180
## 263        3        9
## 264       13       62
## 265       61      348
## 266      308      368
## 267       49       47
## 268       15       18
## 269       68        3
## 270       48       29
## 271       87      165
## 272       44      137
## 273      213      220
## 274      430      267
## 275       54       61
## 276       57       31
## 277       10       89
## 278       64       20
## 279        8        4
## 280       32       19
## 281       36       24
## 282       26       10
## 283       30       22
## 284        6       12
## 285       14        4
## 286       57       12
## 287       23       21
## 288        2        5
## 289        1       21
## 290        2        3
## 291       29       14
## 292        1       14
## 293       55       44
## 294       50       77
## 295        3       21
## 296        6        2
## 297        2        9
## 298       93      578
## 299        0        3
## 300        0        0
## 301    14680     3743
## 302      771     1901
## 303      719       84
## 304      280       46
## 305       55        1
## 306       80      174
## 307      223      182
## 308      115       61
## 309     3490     1098
## 310      121     3084
## 311      139      121
## 312       50      128
## 313      584       74
## 314      197      862
## 315       71       15
## 316      112       42
## 317       98       13
## 318       37        6
## 319       30       48
## 320       14       76
## 321       41      144
## 322       61      228
## 323        1       10
## 324       16       52
## 325      133      456
## 326      350      367
## 327       46       38
## 328       18       19
## 329       47        7
## 330       47       14
## 331      110      175
## 332       46      129
## 333      160      209
## 334      297      229
## 335       68       47
## 336       35       41
## 337       21       83
## 338       51       27
## 339        5        9
## 340       11       27
## 341       31       26
## 342       20       12
## 343       14       19
## 344        2        5
## 345       12        6
## 346       36        9
## 347       10       19
## 348        1        2
## 349        3       18
## 350        0        1
## 351       27        7
## 352        7        6
## 353       47       46
## 354       57       77
## 355        1       12
## 356        1        4
## 357        3        3
## 358      116      662
## 359        0        2
## 360        0        0
## 361    10847     3587
## 362      694     1855
## 363      184       75
## 364      212       50
## 365       23        1
## 366      121      160
## 367      230      146
## 368      108       58
## 369     3062     1049
## 370      142     2828
## 371      128      124
## 372       43      138
## 373      740       78
## 374      336      600
## 375       72       12
## 376       40        5
## 377       81       11
## 378       34       18
## 379       51       56
## 380       38       54
## 381       72      135
## 382      114      212
## 383        4        8
## 384       26       57
## 385      229      471
## 386      190      359
## 387       51       36
## 388       29       16
## 389       81        8
## 390      104       21
## 391      109      164
## 392       44      128
## 393      109      211
## 394      217      207
## 395       36       62
## 396       43       49
## 397       31      100
## 398       35       18
## 399        6        8
## 400       18       19
## 401       13       19
## 402       24       12
## 403       15       13
## 404        6        5
## 405       17        6
## 406       14        8
## 407       13       15
## 408        2        3
## 409        1       11
## 410        8        2
## 411       15        8
## 412        2        6
## 413       57       36
## 414       40       79
## 415        5       14
## 416        8        4
## 417        4        4
## 418      190      719
## 419        1        0
## 420        0        0
## 421    44291     3625
## 422     2957     2195
## 423     1088       73
## 424      474       74
## 425       49        3
## 426      305      144
## 427      814      103
## 428      423       50
## 429     4152     1020
## 430      341     2850
## 431      690      115
## 432      367      206
## 433     1762      106
## 434     1379      590
## 435      212        9
## 436      178       15
## 437      611       14
## 438      212       17
## 439      158       51
## 440       84       47
## 441      271      142
## 442      340      181
## 443       17       10
## 444       63       29
## 445      799      397
## 446     1552      450
## 447      175       43
## 448       98       21
## 449      235       11
## 450      308       18
## 451      592      133
## 452      239      141
## 453     1027      236
## 454     1420      246
## 455      212       87
## 456      401       47
## 457       64       63
## 458      253       29
## 459       32       10
## 460      116       36
## 461      219       35
## 462       95       10
## 463       80       22
## 464       46        6
## 465       78        9
## 466      145       11
## 467      112       17
## 468        6       11
## 469        7       36
## 470       27        4
## 471      162       13
## 472       20        9
## 473      382       38
## 474      108       95
## 475       11       21
## 476        9        1
## 477       11        6
## 478      841      593
## 479        8        1
## 480        0        0
## 481    25545     3873
## 482     1137     2362
## 483      300      112
## 484      256       49
## 485       24        2
## 486      121      203
## 487      279      149
## 488      133       54
## 489     5577     1064
## 490      186     3152
## 491      251      166
## 492       63      137
## 493     1155      122
## 494     1484      853
## 495       93       19
## 496      135       30
## 497      179       17
## 498       37       21
## 499       32       49
## 500       22       81
## 501      185      167
## 502      321      310
## 503        3       11
## 504       42       63
## 505      299      567
## 506      186      421
## 507       31       50
## 508       36       23
## 509       27        3
## 510       77       18
## 511      155      175
## 512       13      156
## 513       89      218
## 514      127      245
## 515       26       81
## 516       18       28
## 517       26       80
## 518       30       27
## 519        4       12
## 520       20       30
## 521       66       26
## 522       17       14
## 523       11       20
## 524        5       11
## 525        7        7
## 526        7        8
## 527       20       15
## 528        3        5
## 529        2       29
## 530        5        3
## 531        8       12
## 532        3        5
## 533       46       48
## 534       10       83
## 535        1       26
## 536        3        0
## 537        7        8
## 538      297     1145
## 539        5        3
## 540        0        0
## 541    12722     3967
## 542      556     1897
## 543      135       81
## 544       76       63
## 545        8        2
## 546       55      195
## 547       84      137
## 548       59       56
## 549     1604     1226
## 550       84     2692
## 551       49      160
## 552       37      199
## 553      271       84
## 554      191      968
## 555       22       18
## 556       55       25
## 557       30       10
## 558       14       11
## 559       12       64
## 560        7       82
## 561       46      179
## 562       64      258
## 563        3       12
## 564       10       87
## 565      104      626
## 566      157      421
## 567       26       37
## 568       15       16
## 569       24        5
## 570       28       18
## 571       48      166
## 572       20      150
## 573      158      207
## 574      201      232
## 575       45       66
## 576       61       28
## 577        4      179
## 578       49       35
## 579        1        5
## 580        9       24
## 581       30       23
## 582        9       14
## 583       10       20
## 584       13        3
## 585       21        3
## 586       14       11
## 587       23       17
## 588        0        2
## 589        0       21
## 590        1        2
## 591       39       12
## 592        4       11
## 593       28       73
## 594       13       90
## 595        0       19
## 596        0        0
## 597        0        9
## 598       65     1050
## 599        0        2
## 600        0        0
## 601    12822     4020
## 602      813     1876
## 603      225       89
## 604      208       76
## 605       13        1
## 606       59      172
## 607      109      142
## 608       94       46
## 609     3116     1334
## 610      100     3386
## 611       70      124
## 612       88      162
## 613      408       73
## 614      295      709
## 615       39       15
## 616       65       25
## 617       37        8
## 618       32       15
## 619       24       46
## 620        6       73
## 621       66      163
## 622       79      224
## 623        3        7
## 624       26       49
## 625       82      527
## 626      402      349
## 627       59       45
## 628       13       16
## 629       84        5
## 630       61        5
## 631       87      199
## 632       40      123
## 633      391      227
## 634      490      225
## 635      103       80
## 636      184       26
## 637       11       91
## 638      121       26
## 639        4        5
## 640       29       27
## 641       93       26
## 642       28       10
## 643       40       23
## 644       15        5
## 645       30        7
## 646       48        8
## 647       76       24
## 648        5        7
## 649        0       16
## 650        3        4
## 651       59       11
## 652        4        4
## 653       58       50
## 654       36       89
## 655        5       23
## 656        3        1
## 657        1        4
## 658      106      903
## 659        0        2
## 660        0        0
## 661    13284     3951
## 662      769     1738
## 663      267       79
## 664      185       49
## 665        9        2
## 666       69      117
## 667      117      126
## 668      119       53
## 669     4005     1136
## 670      100     2183
## 671       89      119
## 672       76      112
## 673      535       65
## 674      252      532
## 675       70        8
## 676       43       34
## 677       57        8
## 678       26       13
## 679       36       37
## 680        7       47
## 681       52      148
## 682       81      166
## 683        5        9
## 684       20       69
## 685      211      390
## 686      355      365
## 687       49       38
## 688       22       13
## 689       62        6
## 690       49        9
## 691      107      172
## 692       47      103
## 693      265      139
## 694      426      203
## 695       39       52
## 696      100       23
## 697        8       60
## 698       68       12
## 699        3        8
## 700       30       22
## 701       62       18
## 702       21       12
## 703       18       14
## 704       13        2
## 705       26        2
## 706       28        7
## 707       29       11
## 708        1        3
## 709        1       18
## 710        4        1
## 711       25       11
## 712        2        7
## 713       51       34
## 714       42       67
## 715        3       14
## 716        0        2
## 717        3        3
## 718       93      644
## 719        0        1
## 720        0        0
## 721    10433     2813
## 722     1035     2804
## 723      285       95
## 724      171       51
## 725       14        4
## 726      211      155
## 727      231       98
## 728      126       44
## 729     3122      747
## 730      166     2094
## 731      139      101
## 732       54       80
## 733      840       83
## 734      625      474
## 735       98        9
## 736      111       51
## 737      130       21
## 738       33       20
## 739       53       35
## 740       27       26
## 741       95      110
## 742      181      166
## 743        5       13
## 744       20       44
## 745      290      352
## 746      286      495
## 747       41       52
## 748       35       15
## 749       65        7
## 750      116       11
## 751      139      192
## 752       72      186
## 753      205      239
## 754      392      303
## 755       55      138
## 756       69       30
## 757       33       78
## 758       65       42
## 759       10       17
## 760       23       29
## 761       12       33
## 762       23       18
## 763       20       25
## 764       10        5
## 765       15       13
## 766       20       11
## 767       23       27
## 768        2        6
## 769        0       37
## 770       13        4
## 771       15       19
## 772        6       10
## 773       82       19
## 774       26       86
## 775        7       10
## 776        1        0
## 777        7       10
## 778      209      492
## 779        1        0
## 780        0        0
## 781    20753      715
## 782     1536     1162
## 783      393       52
## 784      284       24
## 785       22        0
## 786      177       69
## 787      374       47
## 788      185       32
## 789     9647      626
## 790      284      972
## 791      430       68
## 792      132       49
## 793      427       42
## 794     1141      700
## 795      186        7
## 796       78       35
## 797      171       13
## 798       98       11
## 799      124       22
## 800       37       26
## 801      149       85
## 802      236      150
## 803        8        4
## 804       56       25
## 805      316      446
## 806      848      219
## 807      109       16
## 808       71        6
## 809      135        1
## 810      217        4
## 811      288      155
## 812      123       68
## 813      491      133
## 814      907      123
## 815       77       38
## 816      158       16
## 817       52       80
## 818      111        4
## 819       18        5
## 820       54       10
## 821       83       14
## 822       52       12
## 823       62       11
## 824       18        3
## 825       39        4
## 826       97        6
## 827       35        8
## 828        9        4
## 829        4       14
## 830        6        0
## 831       54        7
## 832       12        7
## 833      161       26
## 834       82       44
## 835        5        5
## 836        5        4
## 837        6        7
## 838      431      519
## 839        1        2
## 840        0        0
## 841     7388      115
## 842      868      282
## 843      125        6
## 844       51        4
## 845        4        1
## 846       67       13
## 847      373        6
## 848      124       21
## 849     2200       15
## 850       92       42
## 851      102        4
## 852       13        5
## 853      357        5
## 854      260       19
## 855      109        0
## 856       19        5
## 857       95        4
## 858       21        2
## 859       35       10
## 860       19        1
## 861      133        8
## 862      138       44
## 863        3        2
## 864       12        1
## 865      500       79
## 866       79       47
## 867       21        3
## 868       18        3
## 869       26        1
## 870       46        3
## 871      115       42
## 872       44       26
## 873      121       41
## 874      184       62
## 875       18       13
## 876       29        5
## 877        7       30
## 878       26        6
## 879        6        3
## 880       19        4
## 881       38        4
## 882       12       12
## 883       14        4
## 884        1        1
## 885        5        3
## 886       14        0
## 887        8        6
## 888        2        2
## 889        5        4
## 890        8        0
## 891       10        0
## 892        1        5
## 893       63        1
## 894       12       15
## 895        4        3
## 896        0        0
## 897        0        0
## 898      145      134
## 899        0        0
## 900        0        0
## 901     1112       71
## 902       49       53
## 903       12        8
## 904        8        2
## 905        0        0
## 906        6        1
## 907       83        2
## 908        5        1
## 909     5334        5
## 910        2        7
## 911       61        1
## 912        3        5
## 913      359        2
## 914        1        0
## 915       33        1
## 916        0        5
## 917        4        0
## 918        0        1
## 919        3        4
## 920        2        0
## 921        0        0
## 922       11        4
## 923        0        2
## 924        6        2
## 925        7        5
## 926        7       32
## 927        0        3
## 928        3        2
## 929        1        0
## 930        2        1
## 931        5        4
## 932        0        5
## 933        4        9
## 934        7        8
## 935        2        5
## 936        1        3
## 937        0        0
## 938        1        1
## 939        0        0
## 940        0        5
## 941        0        3
## 942        1        1
## 943        2        1
## 944        0        1
## 945        1        0
## 946        0        1
## 947        0        3
## 948        0        0
## 949        0        6
## 950        0        0
## 951        0        1
## 952        0        0
## 953        1        1
## 954        0        0
## 955        0        0
## 956        0        0
## 957        0        0
## 958       11        5
## 959        0        0
## 960        0        0
category_totals <- colSums(selected_data, na.rm = TRUE)

print(category_totals)
## studying business 
##   459678   200011
category_totals <- colSums(selected_data, na.rm = TRUE)
if (!requireNamespace("scales", quietly = TRUE)) {
  install.packages("scales")
}
library(scales)
category_percentages <- category_totals / sum(category_totals) * 100

pie(
  category_totals,
  labels = sprintf("%s\n%.1f%%", names(category_totals), category_percentages),
  main = "Between Studying and Business by what purpose do vistors visit more"
)