Learn R Programming

MortalityLaws (version 1.4.0)

ReadHMD: Download Mortality and Population Data (HMD)

Description

Download detailed mortality and population data for different countries and regions in a single object from the Human Mortality Database.

Usage

ReadHMD(what, countries = NULL, interval = "1x1", username, password,
  save = TRUE, show = TRUE)

Arguments

what

What type of data are you looking for? There are available: birth records "births", death counts "Dx", deaths by Lexis triangles "lexis", population size "population", exposure-to-risk "Ex", death-rates "mx", life tables for females "LT_f", life tables for males "LT_m", life tables both sexes combined "LT_t", life expectancy at birth "e0", cohort death-rates "mxc" and cohort exposures "Exc".

countries

HMD country codes.

interval

HMD data format: (age interval x year interval). Interval options: 1x1, 1x5, 1x10, 5x1, 5x5, 5x10.

username

Your HMD username. If you don't have one you can sign up for free on Human Mortality Database website.

password

Your HMD password.

save

Do you want to save a copy of the dataset on your local machine?

show

Choose whether to display a progress bar. Logical. Default: TRUE.

Value

An ReadHMD object that contains:

input

List with the input values (except the password).

data

Data downloaded from HMD.

download.date

Time stamp.

years

Numerical vector with the years covered in the data.

ages

Numerical vector with ages covered in the data.

Examples

Run this code
# NOT RUN {
# Download demographic data for 3 countries in 1x1 format 
age_int  <- 1  # age interval: 1,5
year_int <- 1  # year interval: 1,5,10
interval <- paste0(age_int, "x", year_int)  # --> 1x1
# And the 3 countries: Sweden Denmark and USA. We have to use the HMD codes
cntr  <- c('SWE', 'DNK', 'USA')  

# Download death counts. We don't want to export data outside R.
HMD_Dx <- ReadHMD(what = "Dx",
                  countries = cntr,
                  interval  = interval,
                  username  = "user@email.com",
                  password  = "password",
                  save = FALSE)
ls(HMD_Dx)
HMD_Dx

# Download life tables for female population and export data.
LTF <- ReadHMD(what = "LT_f",
               countries = cntr,
               interval  = interval,
               username  = "user@email.com",
               password  = "password",
               save = TRUE)
LTF
# }

Run the code above in your browser using DataLab