knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

ghoR

Travis build status Codecov test coverage

The ghoR package can be used to conventiently load data from the GHO portal of the WHO. The GHO database contains over 20,000 indicators which represent a statistic on a country level.

Installation

You can install the released version of ghoR from CRAN with:

install.packages("ghoR")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("markkvdb/ghoR")

Example

If you are not sure yet which indicator you would like to explore you can discover all indicators by loading it into a dataframe. To prevent downloading the dataset every time you request a dataset, the dataset is saved in ~/.ghoR/. This file is only updated if the WHO website shows that the dataset is last updated after downloading our local version of the dataset.

# First load the library and kable to present table
library(ghoR)
set.seed(420)

# Get a table of all indicators with the code and description.
indicators <- show_GHO_indicators()
indicators_sample <- dplyr::sample_n(indicators, 10)

knitr::kable(indicators_sample)

As an example, we will look at the remaining life expectancy from age $x$ for all available countries, years, sexes and ages. We can load this data using

ex_data <- read_GHO_data("LIFE_0000000035")

knitr::kable(head(ex_data, 10))

Tidying dataset

Datasets downloaded from the WHO website do not follow the tidy philosophy. For the spatial, time and other dimensions, each dimension has a column for the unit of the dimension and one for the value. Most users prefer having their datasets ready for analysis. The ghoR package provides a function to transform the dataset as

tidy_data <- tidy_data(ex_data)

knitr::kable(head(tidy_data, 10))

Updating Datasets

To prevent downloading the dataset every time you request a dataset, the dataset is saved in ~/.ghoR/. This file is only updated if the WHO website shows that the last update date is after the last updated date of the downloaded dataset on the user's computer.



markkvdb/ghoR documentation built on March 2, 2020, 4:52 p.m.