Aug 8, 2018
Goal: visualize first instance decisions on applications by citizenship, age and sex annual aggregated data from Eurostat.
Load libraries:
library(eurostat)
library(data.table)
library(tidyr)
library(magrittr)
library(plyr)
library(dplyr)
library(rjson)
library(viridisLite)
library(highcharter)
Download the data:
if(!file.exists("data_asylum.Rdata")){
data <- "migr_asydcfsta" %>% get_eurostat %>% data.table
save(data, file="data_asylum.Rdata")
}
load("data_asylum.Rdata")
dic <- lapply(names(data), get_eurostat_dic)
eumap <- rjson::fromJSON(file = "http://code.highcharts.com/mapdata/custom/europe.geo.json", method = 'C')
for (i in 1:length(eumap$features))
{
names(eumap$features[[i]][[3]])[names(eumap$features[[i]][[3]]) %in% "iso-a2"] <- "code"
}
data[, period := year(time)]
data[, time := NULL]
data <- data[age %in% "TOTAL" & decision %in% c("TOTAL", "REJECTED") & citizen %in% "TOTAL" & sex %in% "T", ]
data[, geo1 := as.