-
Notifications
You must be signed in to change notification settings - Fork 0
/
hdi.R
61 lines (51 loc) · 2.4 KB
/
hdi.R
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
library(readr)
library(tidyverse)
library(data.table)
library(ggplot2)
library(maps)
library(mapproj)
library(ggthemes)
library(ggrepel)
library(sf)
library(rnaturalearth)
library(cowplot)
#array of former soviet union country ----
soviet_countries <- c("Armenia", "Azerbaijan", "Belarus", "Estonia", "Georgia",
"Kazakhstan", "Kyrgyzstan", "Latvia", "Lithuania", "Moldova",
"Russian Federation", "Tajikistan", "Ukraine", "Uzbekistan")
soviet_iso <- c("ARM", "AZE", "BLR", "EST", "GEO", "KAZ", "KGZ", "LVA", "LTU", "MDA", "RUS", "TJK", "TKM", "UKR", "UZB")
#array of former Warsaw pact country-----
warsaw_pact_country<-c(soviet_countries,"Romania","Czechia","Slovak Republic","Hungary","Poland","Bulgaria")
warsaw_pact_iso <- c("BGR", "CSK", "DDR", "HUN", "POL", "ROU", soviet_iso)
HDI<-read_csv("human-development-index.csv")%>%
filter(Code %in% warsaw_pact_iso,Year==2021)%>%
rename("HDI"="Human Development Index")
HDI1<-read_csv("human-development-index.csv")%>%
filter(Code %in% c("ITA",warsaw_pact_iso),Year==2021)%>%
rename("HDI"="Human Development Index")
#plot a map of gdp x capita of 2021----
world <- ne_countries(scale = "medium", returnclass = "sf")
merged_data<-merge(world,HDI,by.x="sov_a3",by.y="Code")
map_HDI<-merged_data %>%ggplot() +
geom_sf(color = "black", aes(fill = HDI))+
scale_fill_gradient(name="HDI by country 2021",low="lightblue1",high="blue4")+
theme(panel.border = element_blank(), axis.line = element_blank(),
panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_rect(fill = "transparent", color = NA),
axis.text = element_blank(),
axis.title = element_blank(),
axis.ticks = element_blank())+
coord_sf(xlim = c(10, 90))
plot(map_HDI)
#gdp bar----
bar_HDI <-ggplot(HDI1, aes(x = HDI, y = reorder(Entity,HDI),fill=HDI)) +
geom_bar(stat = "identity",orientation="y") +
xlab("") +
ylab("") +
theme(panel.border = element_blank(), axis.line = element_blank(),
panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_rect(fill = "transparent", color = NA),
legend.position = "none")+
scale_fill_gradient(low="lightblue1",high="blue4")
plot(bar_HDI)
plot_grid(bar_HDI, map_HDI, align = "v", axis = "tb", ncol = 2, rel_widths = c(1, 1.5))