forked from Edouard-Legoupil/unhcrdatapackage
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Biggest_increase_in_Refugee_Population.Rmd
70 lines (58 loc) · 2.29 KB
/
Biggest_increase_in_Refugee_Population.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
---
title: "Biggest increase in Refugee Population"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Biggest increase in Refugee Population}
%\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}
## Loading the stat tables
lastyear <- max(unhcrdatapackage::end_year_population_totals_long$Year)
tenyears <- lastyear -10
## Loading the stat tables
data <- dplyr::left_join( x= unhcrdatapackage::end_year_population_totals_long,
y= unhcrdatapackage::reference,
by = c("CountryAsylumCode" = "iso_3")) %>%
filter(Population.type == "REF") %>%
filter(Year == tenyears | Year == lastyear) %>%
group_by( CountryAsylumName, Year) %>%
summarise(Value2 = sum(Value) ) %>%
select(CountryAsylumName, Year, Value2) %>%
mutate(CountryAsylumName = str_replace(CountryAsylumName, "Democratic Republic of the Congo", "DRC")) %>%
mutate(Year = paste0("year_",Year )) %>%
spread(Year, Value2) %>%
mutate(gap = year_2021 - year_2011 ) %>%
arrange(desc(gap)) %>%
head(10)
```
# Generate plot
```{r echo=TRUE, fig.height=7, fig.width=7, warning=FALSE, ,message=FALSE}
ggplot(data, aes(x = year_2011, xend = year_2021,
y = reorder(CountryAsylumName, gap),
group = CountryAsylumName)) +
ggalt::geom_dumbbell(colour = "#dddddd",
size = 3,
colour_x = "#0072bc",
colour_xend = "#FAAB18") +
labs(title = "Where did Refugee Population increased in the past 10 years?",
subtitle = paste0("Biggest increase in Refugee Population, ", tenyears," - ",lastyear),
x="", y ="",
caption = "UNHCR https://www.unhcr.org/refugee-statistics/") +
scale_x_continuous( label = scales::label_number_si()) + ## Format axis number
unhcRstyle::unhcr_theme() + ## Insert UNHCR Style
theme(panel.grid.major.x = element_line(color = "#cbcbcb"),
panel.grid.major.y = element_blank()) ### changing grid line that should appear
```