Runs the requested stage(s) of the SHMD (Spanish subnational Human
Mortality Database) protocol pipeline — retrieval of province-level
births/deaths/population from INE, exposure-to-risk, central death
rates, and period life tables — and writes the results into out_dir
as .csv and/or HMD-format .txt files, so they can be inspected,
shared, or fed into other HMD-compatible tooling without staying in the
R session.
Directory to write into (created if it doesn't exist).
Character vector of stages to include. One or more of
"births", "deaths", "population", "exposure", "mx",
"life_tables". Default: all of them.
Character vector, one or both of "csv" and "txt".
"csv" writes one combined file per data table; "txt" writes
HMD-format files, one per province. Default: both.
Number of most recent years to fetch for the births/deaths/population retrieval stages.
Invisibly, a list with the in-memory results of every stage that
was run (births, deaths, population, exposure, death_rates,
life_tables, each NULL if not run) and files, a character vector
of every path written.
Later stages depend on earlier ones (exposure needs population and
deaths; mx needs deaths and exposure; life_tables needs mx).
Requesting a later stage automatically fetches/computes and writes its
dependencies too, since they were already retrieved along the way.
if (FALSE) { # \dontrun{
# Not run: requires live network access to the INE API, and writes files
# to disk.
# Everything, both formats, into ./ine_data
download_ine_data("ine_data")
# Just births and deaths, CSV only
download_ine_data("ine_data", stages = c("births", "deaths"), format = "csv")
# Full pipeline through life tables
download_ine_data("ine_data", stages = "life_tables", n_periods = 40)
} # }