knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The WHOmortality
R package provides tools to easily download, extract, and import the raw data files found in the World Health Organization's (WHO) Mortality Database. Currently this package only imports the two mortality tables containing the International Classification of Disease, 10th Revision (ICD-10) codes.
You can install the development version of WHOmortality
from the GitHub repository eugejoh/WHOmortality with:
# install.packages("devtools") devtools::install_github("eugejoh/WHOmortality")
The download_who()
function allows the user to download select raw data files and documentation from the WHO website.
library(WHOmortality) dest_dir <- file.path(getwd(), "who_mort_data") dir.create(dest_dir) #create new directory download_who(dest_dir, data = "all") list.files(dest_dir, full.names = TRUE) #see what file were downloaded
The extract_who()
function allows the user to extract the downloaded zip files. This function also adds the .csv
file extension for the appropriate files.
extract_who(dest_dir) #this extracts the zip file contents in the same directory list.files(dest_dir, full.names = TRUE)
The import_who()
function allows the user to choose which raw files to import into R. The example below imports the mortality and population data into R from the locally extracted files. For the ICD-10 mortality tables (part1
and part2
) are automatically combined together after the tables are imported, with a total of 3,767,064 rows. Note the resulting data.frame requires ~1.1GB of memory.
mort_df <- import_who(dest_dir, "mort") pop_df <- import_who(dest_dir, "pop")
The data dictionaries for the mortality and population tables found in the contents of documentation.zip
are tables contained with the WHOmortality
package.
data(dd_mort) #load data dictionary for mortality table data(dd_mort) #load data dictionary for population table data(dd_icd10) #load data dictionary for mortality table cause of death grouping
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.