This project explores the top 10 countries of residence for UNHCR’s populations of concern. The data includes refugees, asylum-seekers, internally displaced persons (IDPs), returned refuggees, returned IDPs, stateless persons and others of concerns. The data is from United Nations Refugee Agency http://popstats.unhcr.org/en/overview
Sweden was the top country of residence in terms of population of concerns in 1990, until it was surpassed by Canada in 1993. Canada remained top 1 until U.S. exceeded it in 1994.
Country of Residence Top Country of Origin 1990-2017
1 Canada Iran (Islamic Rep. of)
2 United States of America Bosnia and Herzegovina
3 Sweden Bosnia and Herzegovina
4 Germany Bosnia and Herzegovina
5 Netherlands Serbia and Kosovo (S/RES/1244 (1999))
6 Australia Albania
7 Switzerland Bosnia and Herzegovina
8 United Kingdom Turkey
9 France Serbia and Kosovo (S/RES/1244 (1999))
10 Belgium Bosnia and Herzegovina
Top Country of Origin in 2017
1 Philippines
2 Mauritania
3 Kenya
4 Dem. People's Rep. of Korea
5 Liberia
6 Saudi Arabia
7 Bulgaria
8 Stateless
9 Iraq
10 Niger
Bosnia and Herzegovina is the top origin for population of concerns residing in five out of the 10 top countries from 1990 to 2017. In 2017 alone, top origin countries differ for these 10 biggest countries of residence. Canada’s top origin country is Phillipines, while U.S. has the most population of concerns from Mauritania.
---
title: "Practice_flexdashboard.rmd"
output:
flexdashboard::flex_dashboard:
orientation: rows
social: menu
source: embed
storyboard: true
---
This project explores the top 10 countries of residence for UNHCR's populations of concern. The data includes refugees, asylum-seekers, internally displaced persons (IDPs), returned refuggees, returned IDPs, stateless persons and others of concerns. The data is from United Nations Refugee Agency http://popstats.unhcr.org/en/overview
### Frame 1: Top 10 Countries of Residence: How the Population Changed Over Time {data-padding=10}
```{r}
data = read.csv("/Users/yh101251/Desktop/HU/512/week7/unhcr_popstats_export_time_series_all_data.csv")
colnames(data)[2] <- "Residence"
data$Value = as.numeric(data$Value)
library(dplyr)
library(ggplot2)
by_residence_90_17 = group_by(filter(data,Year>1989), Residence) %>%
summarise(Total_Population_1990_to_2017 = sum(Value))
top_10_residence_list_90_17= top_n(by_residence_90_17[order(by_residence_90_17$Total_Population_1990_to_2017, decreasing = T),], 10)
top_10_residence_list_90_17$Ranking = seq(from = 1, to = 10, by = 1)
top_10_residence_90_17 = merge(data, top_10_residence_list_90_17, by = "Residence")
top_10_residence_90_17_by_year=group_by(top_10_residence_90_17, Year) %>%
group_by(Year, Residence) %>%
summarise(total = sum(Value))
ggplot(data=filter(top_10_residence_90_17_by_year, Year>1989),
aes(x=Year, y=total, colour=Residence)) +
geom_line() +
theme_bw() +
labs(y="Total Population", x = "Year") +
ggtitle("Top 10 Countries of Residence from 1990 to 2017")
```
***
Sweden was the top country of residence in terms of population of concerns in 1990, until it was surpassed by Canada in 1993. Canada remained top 1 until U.S. exceeded it in 1994.
### Frame2: Top 10 Countries of Residence: Where Are the Population From?
```{r}
library(dplyr)
residence_origin_total_90_17 = group_by(filter(top_10_residence_90_17,Year>1989), Residence) %>%
group_by(Residence, Origin) %>%
summarize(total=sum(Value))
Top_Origin_90_17 = residence_origin_total_90_17 %>%
group_by(Origin) %>%
group_by(Residence) %>%
slice(which.max(total))
colnames(Top_Origin_90_17) = c("Residence", "Top Country of Origin 1990-2017", "Population from the Origin 1990-2017")
residence_origin_total_17 = group_by(filter(top_10_residence_90_17, Year == 2017), Residence) %>%
group_by(Residence, Origin) %>%
summarize(total=sum(Value))
Top_Origin_17 = residence_origin_total_17 %>%
group_by(Origin) %>%
group_by(Residence) %>%
slice(which.max(total))
colnames(Top_Origin_17) = c("Residence", "Top Country of Origin in 2017", "Population of the Origin in 2017")
merged1 = merge(Top_Origin_90_17, Top_Origin_17, by = "Residence")
merged2 = merge(top_10_residence_list_90_17,merged1,by = "Residence")
merged2_sorted=merged2[order(-merged2$Total_Population_1990_to_2017),]
rownames(merged2_sorted) = c("1", "2","3","4","5","6","7","8","9","10")
colnames(merged2_sorted)[1] = "Country of Residence"
colnames(merged2_sorted)[2] = "Total Population 1990-2017"
keeps <- c("Country of Residence", "Top Country of Origin 1990-2017","Top Country of Origin in 2017")
merged2_sorted[keeps]
```
***
Bosnia and Herzegovina is the top origin for population of concerns residing in five out of the 10 top countries from 1990 to 2017. In 2017 alone, top origin countries differ for these 10 biggest countries of residence. Canada's top origin country is Phillipines, while U.S. has the most population of concerns from Mauritania.