Download fertility rate schedules from the Human Fertility Database in the
format that fertility() expects. Requires user name and password and the
HMDHFDplus package.
Usage
get_fertility_hfd(
country,
year,
username = Sys.getenv("HFD_USERNAME"),
password = Sys.getenv("HFD_PASSWORD"),
update = NULL,
by_parity = FALSE
)Arguments
- country
A single HFD population code, such as
"USA".- year
One whole-number calendar year or a nonempty vector of distinct years. All requested years must exist.
- username
HFD username, defaulting to
HFD_USERNAMEenvironmental variable.- password
HFD password, defaulting to
HFD_PASSWORDenvironmental variable.- update
Optional HFD revision date as
"YYYYMMDD", passed asUpdateto HMDHFDplus.NULLrequests its current revision.- by_parity
Logical, default FALSE. TRUE returns conditional rates with
parity_start/parity_endin addition to the age bounds andrate. Requires the HFD conditional-rate product.
Value
A fertility rate tibble with a source attribute recording selected
years and source periods. Multiple years include time_start/time_end;
length-one requests omit them.
Details
To use this function, users will need to install the HMDHFDplus package with:
install.packages("HMDHFDplus")Users will also need to either pass a user name and password to the function
arguments or set the these values in the .Renviron as follows:
A single requested year returns a static schedule without calendar columns.
Multiple years return time_start/time_end for the selected source
periods, in chronological order.
HFD endpoint rows retained: 12- is represented as [12,13) using its
supplied rate, and 55+ as [55,Inf).
