An open API service indexing awesome lists of open source software.

https://github.com/markkvdb/ghor

R interface for the GHO API of the WHO
https://github.com/markkvdb/ghor

Last synced: 9 months ago
JSON representation

R interface for the GHO API of the WHO

Awesome Lists containing this project

README

          

---
output: github_document
---

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

# ghoR

[![Travis build status](https://travis-ci.org/markkvdb/ghoR.svg?branch=master)](https://travis-ci.org/markkvdb/ghoR)
[![Codecov test coverage](https://codecov.io/gh/markkvdb/ghoR/branch/master/graph/badge.svg)](https://codecov.io/gh/markkvdb/ghoR?branch=master)

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](https://CRAN.R-project.org) with:

``` r
install.packages("ghoR")
```

And the development version from [GitHub](https://github.com/) with:

``` r
# 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.

```{r example-load}
# 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

```{r example-indicator}
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

```{r example-tidy}
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.