Extracts births and/or deaths data for a given country and time period from the UNDP portal.
The Location Id for each country. Run DemoTools::get_locations()
to get information about available locations. The ids are indicated in the PK_LocID
variable.
The type of data to be pulled i.e. births/deaths.
The data collection process i.e. Census (census) or Vital Registrations (vr).
The minimum year for the data to be extracted.
The maximum year for the data to be extracted.
NULL.
NULL.
A dataset showing counts for each location, type of data (births or deaths), process, year, sex and age label.
This function extracts data using get_recorddata().
The function returns NULL
in cases where the data is not available and a dataframe of 93 variables where it exists.
In cases where the user inserts an invalid location id, a message is returned prompting them to run View(get_locations())
to get a list of plausible location ids. See
check_locid for more details on this. You can run getAnywhere(DDextract_VitalCounts)
to see how the function is defined.
if (FALSE) {
# Extracting births data
births_df <- DDextract_VitalCounts(404, #Kenya
type = c("births"),
process = c("census","vr"),
1950,
2050,
DataSourceShortName = NULL,
DataSourceYear = NULL)
# Extracting deaths data
deaths_df <- DDextract_VitalCounts(364, #Iran
type = c("deaths"),
process = c("census","vr"),
1950,
2050,
DataSourceShortName = NULL,
DataSourceYear = NULL)
}