library(dplyr)
library(readxl)
library(tidyr)
library(ggplot2)
library(reshape)
library(tidyverse)
library(scales)
library(openxlsx)
options(dplyr.summarise.inform = FALSE)
3 ShinyApp Assignment
Data Wrangling
First of all, I installed packages.
I fetched raw data and stored in students variable.
<-read_excel("foreign_students_by_nationality_2021_2022.xlsx") students
I high-level look at raw data which has 7 columns and 10.461 rows.
%>% glimpse() students
Rows: 10,461
Columns: 7
$ `Üniversite Adı` <chr> "ABDULLAH GÜL ÜNİVERSİTESİ", "ABDULLAH GÜL ÜNİVERSİT…
$ `Üniversite Türü` <chr> "DEVLET", "DEVLET", "DEVLET", "DEVLET", "DEVLET", "D…
$ `İl Adı` <chr> "KAYSERİ", "KAYSERİ", "KAYSERİ", "KAYSERİ", "KAYSERİ…
$ Uyruk <chr> "AFGANİSTAN İSLAM CUMHURİYETİ", "ALMANYA FEDERAL CUM…
$ E <chr> "1", "1", "0", "8", "4", "1", "1", "1", "1", "1", "1…
$ K <chr> "0", "0", "1", "2", "3", "0", "0", "1", "2", "0", "0…
$ T <chr> "1", "1", "1", "10", "7", "1", "1", "2", "3", "1", "…
I changed column names so that I could omit white spaces and Turkish characters.
<- c("university","university_type","country","nationality","male","female","total")
new_cols
colnames(students) <- new_cols
I removed any incomplete cases.
<- na.omit(students) students
I selected columns from university to female.
<- students %>%
students select('university':'female')
I unpivoted male and female column as gender column by using melt function.
<- reshape2::melt(students, id = c("university", "university_type", "country", "nationality"), variable.name = "gender", value.name="count") students
I converted count column as numeric.
$count <- as.numeric(students$count) students
I saved file as RDS.
saveRDS(data, file = "apps/foreign_students_app/students.Rds")
I created another excel file named foreign_students.xlsx derived from raw data. I used this file in shiny app.
write.xlsx(students, "ForeignStudentAnalysis/foreign_students.xlsx")
Shinyapps.io
Command for local running
::runGitHub(repo = "pjournal/mef06-avagcanseza",subdir="apps/foreign_students_app") shiny