wbgdata
, wbgcharts
, wbggeo
and wbgmaps
This repo is a collection of packages for standardising visualizations for (initially) the WDI and SDG Atlas. It comprises three packages:
wbstats
package to make using data easier and more efficientggplot2
for figures styling, and outputggplot
understands, so no supporting geospatial libraries are needed.Note that if you are producing maps for official World Bank publications it is extremely important to use the wbgmaps
basemaps.
Each of the four packages must be installed separately. Steps from within R/RStudio:
devtools
installed from CRAN: install.packages('devtools')
devtools::install_github("worldbank/wbgviz", subdir = "wbgdata")
devtools::install_github("worldbank/wbgviz", subdir = "wbgcharts")
devtools::install_github("worldbank/wbgviz", subdir = "wbggeo")
devtools::install_github("worldbank/wbgviz", subdir = "wbgmaps")
Note that by default install_github
does not create vignettes - you can enable this by adding an argument build_vignettes = TRUE
to each of the three above commands. Then you can view the vignettes included in a package by e.g. vignette(package="wbgcharts")
.
To use styles, you need to have font dependencies. One (Avenir) is a commerical license so we can't distribute with the package. Assuming it is already installed on your system, the following may work:
font_import()
This will take a while. When it completes, see if Avenir is now included in the font list by examing:
View(fonttable()
Chances are, it won't work, because Avenir is wrapped up in a .ttc
file that extrafont
doesn't recognise. Various tools will extract .ttc
files into .ttf
files, or you can ask @EconAndrew for the pre-extracted fonts (if you have a license).
If you don't have Avenir, style_atlas_open
and style_worldbank.org
substitute similar open fonts that can be installed using:
install.packages("extrafont")
font_import(system.file("fonts", package = "wbgcharts"))
You will probably need to install them at the OS level too. Usually this is by opening the path printed by
system.file("fonts", package = "wbgcharts")
then double clicking or right clicking on the fonts there.