forked from Edouard-Legoupil/unhcrdatapackage
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Asylum_processing.Rmd
106 lines (89 loc) · 3.91 KB
/
Asylum_processing.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
---
title: "Asylum Processing"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Asylum Processing}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
echo=TRUE,
comment = "#>"
)
```
## Load Packages
```{r message=FALSE, warning=FALSE}
library(tidyverse)
```
## Prepare Data
```{r}
thisbureau <- "Americas"
lastyear <- max(unhcrdatapackage::end_year_population_totals_long$Year)
end_year_population_totals_long.asy <- dplyr::left_join( x= unhcrdatapackage::end_year_population_totals_long,
y= unhcrdatapackage::reference,
by = c("CountryAsylumCode" = "iso_3"))
asylumseekerAM2020 <- end_year_population_totals_long.asy %>%
filter(Population.type %in% c("ASY") &
Year == lastyear &
UNHCRBureau == thisbureau &
!(is.na(UNHCRBureau)) ) %>%
group_by( CountryAsylumName) %>%
summarise(Asylum = sum(Value) ) %>%
filter(Asylum > 50000)
asylum_decisionAM <- unhcrdatapackage::asylum_decisions %>%
## Add reference for the filters
dplyr::left_join( unhcrdatapackage::reference %>%
select(coa_region = `UNHCRBureau`, iso_3), by = c("CountryAsylumCode" = "iso_3")) %>%
filter(coa_region == thisbureau #& Year == lastyear
) %>%
group_by(CountryAsylumName, Year ) %>%
mutate(Year = as.integer(Year) ) %>%
summarise(Decided = sum(TotalDecided) ) %>%
filter(CountryAsylumName %in% as.character(asylumseekerAM2020$CountryAsylumName))
asylum_applicationsAM <- unhcrdatapackage::asylum_applications %>%
## Add reference for the filters
dplyr::left_join( unhcrdatapackage::reference %>%
select(coa_region = `UNHCRBureau`, iso_3),
by = c("CountryAsylumCode" = "iso_3")) %>%
filter(coa_region == thisbureau #& Year == lastyear
) %>%
group_by(CountryAsylumName, Year ) %>%
mutate(Year = as.integer(Year) ) %>%
summarise(Applied = sum(NumberApplications) ) %>%
filter(CountryAsylumName %in% as.character(asylumseekerAM2020$CountryAsylumName)) %>%
filter(Year > 2017) %>%
dplyr::left_join( asylum_decisionAM, by = c("CountryAsylumName", "Year")) %>%
mutate(applicationrate = Decided / Applied * 100 ) %>%
mutate(applicationrate.cat = cut(applicationrate, breaks=c(0, 25, 50, 75,100, 500)))
```
## Generate plot
```{r echo=TRUE, fig.height=7, fig.width=7, warning=FALSE, ,message=FALSE}
## First test combine Number of Application & Ratio as color
rsdrate <- ggplot(asylum_applicationsAM,
aes(x = reorder(CountryAsylumName, Applied),
y = Applied,
fill= applicationrate.cat )) +
geom_bar( stat ="identity") +
#scale_fill_grey(start = 0.85, end = 0.15) +
#scale_fill_gradient(low = "#132B43", high = "#56B1F7") +
scale_fill_brewer(palette = "RdYlGn") +
#scale_fill_brewer(direction = -1) +
coord_flip() +
facet_wrap( vars(Year ), ncol = 3) +
scale_y_continuous( label = unhcRstyle::format_si()) + ## Format axis number
theme(legend.position="none") +
geom_hline(yintercept = 0, size = 1.1, colour = "#333333") +
unhcRstyle::unhcr_theme(base_size = 8) + ## Insert UNHCR Style
theme(panel.grid.major.x = element_line(color = "#cbcbcb"),
panel.grid.major.y = element_blank(),
panel.grid.minor = element_blank()) + ### changing grid line that should appear
## and the chart labels
labs(title = "How much Status decision processing capacity are addressing the demand in the Americas?",
subtitle = "Colors indicate the ratio between Numbers of Asylum Applications and Decisions ",
x = "Number of applications",
y = "",
caption = "Source: UNHCR.org/refugee-statistics - only for countries with more than 50,000 Asylum Seekers")
rsdrate
```