readJMDweb: read data from the Japan Mortality Database into R

View source: R/readHMD.R

readJMDwebR Documentation

read data from the Japan Mortality Database into R

Description

JMD data are formatted exactly as HMD data. This function simply parses the necessary url together given a prefecture code and data item (same nomenclature as HMD). Data is parsed using HMDparse(), which converts columns into useful and intuitive classes, for ready-use. See ?HMDparse for more information on type conversions. No authentication is required for this database. Only a single item/prefecture is downloaded. Loop for more complex calls (See examples). The prefID is not appended as a column, so be mindful of this if appending several items together into a single data.frame. Note that at the time of this writing, the finest Lexis resolution for prefectural lifetables is 5x5 (5-year, 5-year age groups). Raw data are, however, provided in 1x1 format, and deaths are also available in triangles.

Usage

readJMDweb(prefID = "01", item = "Deaths_5x5", fixup = TRUE, ...)

Arguments

prefID

a single prefID 2-digit character string, ranging from "00" to "47".

item

the statistical product you want, e.g., "fltper_5x5". Only 1.

fixup

logical. Should columns be made more user-friendly, e.g., forcing Age to be integer?

...

extra arguments ultimately passed to read.table(). Not likely needed.

Details

No details of note. This database in independently maintained, so file types/locations are subject to change. If this happens, please notify the package maintainer.

Value

data.frame of the data item is invisibly returned

Examples

## Not run: 
library(HMDHFDplus)
# grab prefecture codes (including All Japan)
prefectures <- getJMDprefectures()
# grab all mltper_5x5
# and stick into long data.frame: 
mltper <- do.call(rbind, lapply(prefectures, function(prefID){
                   Dat        <- readJMDweb(prefID = prefID, item = "mltper_5x5", fixup = TRUE)
                   Dat$PrefID <- prefID
                   Dat
}))

## End(Not run)


HMDHFDplus documentation built on July 9, 2023, 6:26 p.m.