Coder Social home page Coder Social logo

wbgviz's Introduction

WBGviz - comprising 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:

  • wbgdata - a wrapper for the wbstats package to make using data easier and more efficient
  • wbgcharts - a variety of extensions to ggplot2 for figures styling, and output
  • wbggeo - specific extensions for map output (not needed if not producing maps)
  • wbgmaps - a package containing WBG-compliant mapping base layers (rendering borders, etc as per Style Guide Appendix H). These are already bundled into a format ggplot 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.

Installation (NOT TESTED)

Each of the four packages must be installed separately. Steps from within R/RStudio:

  1. Make sure you have devtools installed from CRAN: install.packages('devtools')
  2. (While this repo is private) You need to generated a Github access token to install R packages from private repos:
  • Go to https://github.com/settings/tokens/new
  • Enter something in description and check the [x] repo box.
  • Choose generate token
  • Take a note of the token [SECRET] - you won't be able to see it again (although you can always delete it and generate another)
  1. Use devtools to install each package in turn:
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").

Font installation

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.

wbgviz's People

Contributors

econandrew avatar tonyfujs avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.