forked from worldbank/sdgatlas2018
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit fe88615
Showing
471 changed files
with
497,104 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# History files | ||
.Rhistory | ||
.Rapp.history | ||
# Session Data files | ||
.RData | ||
# Example code in package build process | ||
*-Ex.R | ||
# Output files from R CMD build | ||
/*.tar.gz | ||
# Output files from R CMD check | ||
/*.Rcheck/ | ||
# RStudio files | ||
.Rproj.user/ | ||
# produced vignettes | ||
vignettes/*.html | ||
vignettes/*.pdf | ||
# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 | ||
.httr-oauth | ||
# knitr and R markdown default cache directories | ||
/*_cache/ | ||
/cache/ | ||
# Temporary files created by R markdown | ||
*.utf8.md | ||
*.knit.md | ||
.Rproj.user | ||
#Mac nonsense | ||
.DS_Store |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# Installation / replication steps | ||
|
||
Depending on your own system setup you may not need to do all of this. This assumes you are starting from nothing (not even a sytem running R, but a lowest-common-denominator cloud hosted linux instance). | ||
|
||
If you already have some sort of system, possibly running R already, you should probably start from step 2, 5, or 7. The library installs etc will vary depending on your package manager. We may eventually set up a docker image for the project to avoid this. | ||
|
||
1. If necessary create your VM, for example I used the default AWS EC2 image. | ||
- allocate public IP address | ||
- open incoming TCP port 8787 in AWS console security group | ||
|
||
2. Install docker | ||
- Instructions here: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html | ||
|
||
3. Launch docker with R Studio (based on [this guide](https://ropenscilabs.github.io/r-docker-tutorial/02-Launching-Docker.html)) | ||
|
||
``` | ||
docker run --rm -p 8787:8787 rocker/verse | ||
``` | ||
|
||
4. Connect to your VM instance (e.g. if on AWS, ssh in from another local terminal). Then at the remote shell, connect do Docker: | ||
|
||
``` | ||
# Get the container-id | ||
docker ps | ||
# Use the reported container-id below | ||
docker exec -it <container-id> bash | ||
``` | ||
|
||
5. install some system packages. From with the docker shell | ||
|
||
``` | ||
apt-get update | ||
# for mogrify | ||
apt-get install imagemagick php-imagick -y | ||
# for proj4 | ||
apt-get install libproj-dev proj-data proj-bin -y | ||
# for rgdal | ||
apt-get install libgdal-dev python-gdal gdal-bin -y | ||
# for pdftools | ||
apt-get install libpoppler-cpp-dev -y | ||
``` | ||
|
||
6. Connect to RStudio at your VM's address port 8787. Login as 'rstudio' pass 'rstudio'. | ||
|
||
7. Install some standard packages the base docker image lacks. In RStudio console | ||
|
||
``` | ||
install.packages(c("countrycode","ggalluvial","ggmosaic","pdftools","png","proj4" ,"readstata13","rgdal", "OECD")) | ||
``` | ||
|
||
8. Clone the repo. In RStudio terminal | ||
|
||
``` | ||
git clone https://github.com/worldbank/sdgatlas2018.git | ||
``` | ||
|
||
8. Install some development packages we created. In RStudio console: | ||
|
||
``` | ||
devtools::install_github("worldbank/wbgviz", subdir = "wbgdata") | ||
devtools::install_github("worldbank/wbgviz", subdir = "wbgcharts") | ||
devtools::install_github("worldbank/wbgviz", subdir = "wbgmaps") | ||
devtools::install_github("worldbank/wbgviz", subdir = "wbggeo") | ||
9. As of now `ggtreemap` doesn't work with the latest treemapify, so in RStudio console: | ||
``` | ||
devtools::install_version("treemapify", version = "2.4.0") | ||
devtools::install_github("econandrew/ggtreemap") | ||
``` | ||
9. If you want to use the nearest open fonts | ||
- In RStudio console | ||
``` | ||
extrafont::font_import(system.file("fonts", package = "wbgcharts")) | ||
``` | ||
- You will also need to install these fonts at system level (OS dependent) | ||
10. Update the cached API data so everything runs smoothly. In RStudio console | ||
``` | ||
wbgdata::refresh_wbcache() | ||
``` | ||
11. Open the sdgatlas2018 project in RStudio | ||
12. In RStudio console, the following we remake all figures from scratch. | ||
``` | ||
source("make.R") | ||
make_all("docs", styler = style_atlas_open) | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# SDG Atlas 2018 code for analysis & figures | ||
|
||
This respository contains code and some data for the World Bank's Atlas of Sustainable | ||
Development Goals 2018. | ||
|
||
If you simply want to understand how a particular figure was derived, what | ||
transformations were made and with what assumptions, it is probably easiest to | ||
just browse the code on Github. To help navigate the repo, see 'Contents' below. | ||
|
||
If you want to be able to rebuild some or all of the figures, see 'Installation'. | ||
|
||
## Note on non-R maps | ||
|
||
Fifteen more complex maps (rasters & other detail) were produced using QGIS. These | ||
are not included in this repository due to the large file sizes associated with | ||
raster map data. | ||
|
||
They can be found in the World Bank Data Catalogue, along with an archive of this | ||
respository, at: | ||
|
||
TODO | ||
|
||
## Contents | ||
|
||
### *.R | ||
|
||
Each chapter has an R script associated with it. Figures within the chapter are | ||
self contained functions, with names that (usually) match the rendered figure's | ||
filename. | ||
|
||
With in each file, `make_all()` will re-render PNGs in the default style and location. | ||
|
||
`make_all()` in `make.R` will re-render all the figures. | ||
|
||
### docs/ | ||
|
||
Contains the rendered figures. | ||
|
||
### inputs/ | ||
|
||
Contains any data which was not available via the World Bank or another API. | ||
|
||
## Installation | ||
|
||
A complete installation / replication guide is given in [INSTALL.md](INSTALL.md). | ||
|
||
This repository depends on the [`wbgviz`](https://github.com/worldbank/sdgatlas2018) custom R packages. | ||
|
||
Some parts depend a submodule of restricted data that we cannot make public. | ||
|
||
https://github.com/worldbank/sdgatlas2018-restricted/ | ||
|
||
### To clone the restricted submodule as well (World Bank users) | ||
|
||
To clone, first clone as usual then within the git folder hierarchy, then to get the submodules run | ||
|
||
`git submodule update --init` | ||
|
||
Alternatively to clone the repo including submodules in one go, you can try the `--recursive` flag: | ||
|
||
`git clone --recursive` | ||
|
||
## Errata | ||
|
||
### Without history | ||
|
||
We have corrected a small number of errors between finalization of the print publication and release of this repository. The history of these errata is not present in repository. Any further errata will be corrected as new commits. | ||
|
||
#### docs/sdg4/fig_sdg4_school_facilities.png | ||
|
||
Data for this figure are not currently published. | ||
|
||
#### docs/sdg8/fig_sdg8_account_map2.png | ||
|
||
Data were revised prior to finalization. | ||
|
||
#### docs/sdg10/fig_sdg10_b40_explainer | ||
|
||
Data were revised prior to finalization. | ||
|
||
#### docs/sdg12/fig_sdg12_landfill_map.png | ||
|
||
The data dates given in the subtitle were incorrectly listed as 2012-14. | ||
|
||
#### docs/sdg12/fig_sdg12_recycle_compost_map | ||
|
||
Figure updated to take a more conservative approach to handling 'no data' values. | ||
|
||
#### docs/sdg5/fig_sdg5_domesticviolence.png | ||
|
||
Incorrect/ambiguous source given. | ||
|
||
### With history | ||
|
||
None. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
library(ggplot2) | ||
library(dplyr) | ||
library(tidyr) | ||
library(stringr) | ||
library(extrafont) | ||
library(forcats) | ||
library(wbgdata) | ||
library(wbgcharts) | ||
library(wbgmaps) | ||
library(wbggeo) | ||
source("styles.R") | ||
|
||
abouttheatlas_example <- function(startdate = 2011, enddate = 2016) { | ||
indicator <- "SE.PRE.ENRR" | ||
df <- wbgdata(wbgref$countries$iso3c, indicator, startdate = startdate, enddate = enddate, removeNA = TRUE) | ||
df <- df %>% | ||
group_by(iso3c) %>% | ||
filter(date == max(date)) %>% | ||
ungroup() | ||
df <- df %>% right_join(data.frame(iso3c = wbgref$countries$iso3c, stringsAsFactors=FALSE)) | ||
df$bins <- supercut(df$SE.PRE.ENRR, c( | ||
"0–25" = "[0,25)", | ||
"25–50" = "[25,50)", | ||
"50–75" = "[50,75)", | ||
"75 and over" = "[75,Inf)" | ||
)) | ||
|
||
figure( | ||
data = df, | ||
plot = function(df, style = style_atlas(), quality = "low") { | ||
g <- wbg_choropleth(df, wbgmaps[[quality]], style, variable = "bins") | ||
g$theme <- style$theme() | ||
g | ||
}, | ||
aspect_ratio = 1.5, | ||
# title = "Despite evidence of the importance of pre-primary education, enrollment is still far from universal", | ||
title = "Example: Despite its importance, enrollment in pre-primary education is not universal.", | ||
note = "Note: Explanations about data selection, calculations and definitions appear in notes. a. Footnotes appear like this.", | ||
subtitle = wbg_name(indicator = "Gross pre-primary enrollment ratio", mrv = df$date, denom = "%"), | ||
source = paste("Source:", "UNESCO Institute for Statistics. World Development Indicators (SE.PRE.ENRR).") | ||
) | ||
} | ||
|
||
make_all("docs/abouttheatlas/pdf", style_atlas_cmyk, figure_save_final_pdf) | ||
make_all <- function(path = "docs/abouttheatlas", styler = style_atlas, saver = figure_save_draft_png) { | ||
#page 1 | ||
saver(abouttheatlas_example(), styler, file.path(path, "abouttheatlas_example.png"), width = 5.7, height = 4) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# SDG Atlas 2018 output figures | ||
|
||
The output figures are in this folder, organized by chapter. Each folder contains draft RGB PNG figures and a subfolder `/pdf` with final CMYK PDF figures. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# SDG Atlas 2018 data sources | ||
|
||
The majority of the data for the Atlas comes from the World Development Indicators, and | ||
is accessed directly using the World Bank Data API via the `wbstats` R package | ||
and our custom internal wrapper of that `wbgdata()`. | ||
|
||
However, a substantial minority of the figures use data from other sources, including | ||
other World Bank datasets, datasets published by other international organizations, | ||
and academic datasets. | ||
|
||
These other datasets are archived within these folders, by chapter / goal. | ||
|
||
A small number of datasets related to goal 7 and goal 13 are restricted from | ||
distribution. These have been removed from the restricted/ subfolder, and | ||
you will not be able to rebuild the figures that rely on these datasets. For | ||
further information on these datasets in particular, contact any of: | ||
|
||
Tariq Khokhar <[email protected]> | ||
|
||
Andrew Whitby <[email protected]> | ||
|
||
Umar Serajuddin <[email protected]> |
Oops, something went wrong.