readCHMDweb | R Documentation |
CHMD data are formatted exactly as HMD data. This function simply parses the necessary url together given a province 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 provID 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. Note that cohort data are not produced for Canada at this time (but you could produce such data by starting with the Deaths\_Lexis
file...).
readCHMDweb(provID = "can", item = "Deaths_1x1", fixup = TRUE, ...)
provID |
a single provID 3 character string, as returned by |
item |
the statistical product you want, e.g., |
fixup |
logical. Should columns be made more user-friendly, e.g., forcing Age to be integer? |
... |
extra arguments ultimately passed to |
This database is curated independently from the HMD/HFD family, and so file types and locations may be subject to change. If this happens, please notify the package maintainer.
data.frame
of the data item is invisibly returned
## Not run:
library(HMDHFDplus)
# grab province codes (including All Canada)
provs <- getCHMDprovinces()
# grab all mltper_5x5
# and stick into long data.frame:
mltper <- do.call(rbind, lapply(provs, function(provID){
Dat <- readCHMDweb(provID = provID, item = "mltper_5x5", fixup = TRUE)
Dat$provID <- provID
Dat
}))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.