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
- Host: GitHub
- URL: https://github.com/markkvdb/ghor
- Owner: markkvdb
- License: other
- Created: 2019-12-20T23:50:29.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-26T21:56:07.000Z (over 6 years ago)
- Last Synced: 2025-07-04T08:40:00.130Z (12 months ago)
- Language: R
- Size: 132 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
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
[](https://travis-ci.org/markkvdb/ghoR)
[](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.