Learn R Programming

MortalitySmooth (version 1.0)

selectHMDdata: Selecting Data from the HMDdata Object

Description

Creates subset of the HMDdata object.

Usage

selectHMDdata(country,
              data = c("Population", "Deaths", "Exposures", "Rates"), 
              sex = c("Females", "Males", "Total"), 
              ages = NULL, years = NULL)

Arguments

country
Character string for the country name.
data
Character string showing type of demographic series: either "Population", "Deaths", "Exposures" or "Rates". Default value "Population".
sex
Character string showing sex of demographic series: either "Females", "Males" or "Total". Default value "Females".
ages
Vector of ages to extract from data. If it is NULL, all ages will be selected.
years
Vector of years to extract from data. If it is NULL, all available years will be selected.

Value

  • Matrix object from HMDdata but with a subset of country, type of data, sex, ages and years.

Details

The function needs HMDdata to be uploaded. Country names is not case-sensitive and initials can be used. However, distinguishable country name is necessary. Type of data and sex are case-sensitive and initials can be used. Available ages are always from 0 to 110, whereas years depends on the country. Warning massages will be provided in case of selected default values. Attributes about country, data and sex will be given to the outcome.

See Also

HMDdata.

Examples

Run this code
data(HMDdata)
# "Complete" example
x <- 1950:2000
den50 <- selectHMDdata("Denmark", "Death", "Females", 50, x)
plot(x, den50, main="Danish female deaths at age 50")
# "Incomplete" example with warning
jap50 <- selectHMDdata("jap", "Pop", "F", 50)
## Wrong example (don't run)
# selectHMDdata("Sw", "Pop", "F", 50, 2000)
## Sw can stand for both Sweden and Switzerland

Run the code above in your browser using DataLab