Created
May 4, 2022 20:43
-
-
Save randrescastaneda/12d92461c270af34e5c1fbae5f66955f to your computer and use it in GitHub Desktop.
Compare versions of PIP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ____________________________________________________________________________ | |
# country level #### | |
sr0 <- pipr::get_stats("SYR", fill_gaps = TRUE, server = "dev") | |
sr1 <- | |
pipr::get_stats("SYR", | |
fill_gaps = TRUE, | |
server = "dev", | |
version = "20220428_2011_02_02_PROD") | |
setDT(sr0) | |
setDT(sr1) | |
to_keep <- c("country_code", "year", "headcount", "mean") | |
sr0 <- sr0[, ..to_keep] | |
sr1 <- sr1[, ..to_keep] | |
setnames(sr0, c("headcount", "mean"), c("hc_0503", "mn_0503")) | |
setnames(sr1, c("headcount", "mean"), c("hc_0408", "mn_0408")) | |
sr <- joyn::merge(sr0, sr1, reportvar = FALSE) | |
sr <- sr[year >= 2010] | |
sr <- | |
melt(sr, | |
measure.vars = patterns(headcount = "^hc_", mean = "^mn_"), | |
id.vars = "year", | |
variable.name = "source") | |
sr_hc <- | |
ggplot(sr, aes(x = year, | |
y = headcount, | |
color = source)) + | |
geom_line() + | |
geom_point() + | |
theme_minimal() + | |
theme( | |
legend.position = "bottom", | |
legend.title = element_blank() | |
) + | |
scale_colour_discrete(labels = c("May 03", "Apr 08")) + | |
labs(y = "Poverty headcount (\\$1.9)", | |
title = "Syria (Poverty)") | |
sr_hc | |
sr_mn <- | |
ggplot(sr, aes(x = year, | |
y = mean, | |
color = source)) + | |
geom_line() + | |
geom_point() + | |
theme_minimal() + | |
theme( | |
legend.position = "bottom", | |
legend.title = element_blank() | |
) + | |
scale_colour_discrete(labels = c("May 03", "Apr 08")) + | |
labs(y = "Mean", | |
title = "Syria (Mean)") | |
sr_mn | |
# ____________________________________________________________________________ | |
# regional level #### | |
sr0 <- pipr::get_wb(server = "dev") | |
sr1 <- | |
pipr::get_wb(server = "dev", | |
version = "20220428_2011_02_02_PROD") | |
setDT(sr0) | |
setDT(sr1) | |
to_keep <- c("region_code", "year", "headcount", "mean") | |
sr0 <- sr0[, ..to_keep] | |
sr1 <- sr1[, ..to_keep] | |
setnames(sr0, c("headcount", "mean"), c("hc_0503", "mn_0503")) | |
setnames(sr1, c("headcount", "mean"), c("hc_0408", "mn_0408")) | |
sr <- joyn::merge(sr0, sr1, reportvar = FALSE) | |
sr <- sr[year >= 2010] | |
sr <- | |
melt(sr, | |
measure.vars = patterns(headcount = "^hc_", mean = "^mn_"), | |
id.vars = c("region_code", "year"), | |
variable.name = "source") | |
mna <- sr[region_code == "MNA"] | |
mna_hc <- | |
ggplot(mna, aes(x = year, | |
y = headcount, | |
color = source)) + | |
geom_line() + | |
geom_point() + | |
theme_minimal() + | |
theme( | |
legend.position = "bottom", | |
legend.title = element_blank() | |
) + | |
scale_colour_discrete(labels = c("May 03", "Apr 08")) + | |
labs(y = "Poverty headcount (\\$1.9)", | |
title = "Middle East and North Africa (Poverty)") | |
mna_hc | |
mna_mn <- | |
ggplot(mna, aes(x = year, | |
y = mean, | |
color = source)) + | |
geom_line() + | |
geom_point() + | |
theme_minimal() + | |
theme( | |
legend.position = "bottom", | |
legend.title = element_blank() | |
) + | |
scale_colour_discrete(labels = c("May 03", "Apr 08")) + | |
labs(y = "Mean", | |
title = "Middle East and North Africa (Mean)") | |
mna_mn | |
# ____________________________________________________________________________ | |
# world #### | |
wld <- sr[region_code == "WLD"] | |
wld_hc <- | |
ggplot(wld, aes(x = year, | |
y = headcount, | |
color = source)) + | |
geom_line() + | |
geom_point() + | |
theme_minimal() + | |
theme( | |
legend.position = "bottom", | |
legend.title = element_blank() | |
) + | |
scale_colour_discrete(labels = c("May 03", "Apr 08")) + | |
labs(y = "Poverty headcount (\\$1.9)", | |
title = "World (Poverty)") | |
wld_hc | |
wld_mn <- | |
ggplot(wld, aes(x = year, | |
y = mean, | |
color = source)) + | |
geom_line() + | |
geom_point() + | |
theme_minimal() + | |
theme( | |
legend.position = "bottom", | |
legend.title = element_blank() | |
) + | |
scale_colour_discrete(labels = c("May 03", "Apr 08")) + | |
labs(y = "Mean", | |
title = "World (Mean)") | |
wld_mn | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment