# Init ------------------------------------------------
library(dplyr) # data verbs, operations on subsets of data
library(hmdget) # download data from human mortality database
# System ----------------------------------------------
# System info
sessionInfo()
# Defaults --------------------------------------------
# HMD login information
username <- "***"; password <- "***"
# Test ------------------------------------------------
# download period and cohort exposures for all HMD countries
Dx <- HMDget(hmdcbook$Code, .timeframe = "p+c", .measure = "Dx",
.username = username, .password = password)
Nx <- HMDget(hmdcbook$Code, .timeframe = "p+c", .measure = "Nx",
.username = username, .password = password)
mx <- HMDget(hmdcbook$Code, .timeframe = "p+c", .measure = "mx",
.username = username, .password = password)
# check
Dx %>% filter(Country == "GBRCENW", Year == 1939, Age == 100)
Nx %>% filter(Country == "POL", Year == 1939, Age == 40)
mx %>% filter(Country == "SWE", Year == 1900, Age == 100)
# join Dx and Nx, remove rows with NAs
full_join(Dx, Nx) %>% na.omit -> hmd
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.