Learn R Programming

MortalitySmooth (version 2.3.4)

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 with a subset of country, type of data, sex, ages and years.

Details

HMDdata are loaded with the package. 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.

References

Camarda, C. G. (2012). MortalitySmooth: An R Package for Smoothing Poisson Counts with P-Splines. Journal of Statistical Software. 50, 1-24. http://www.jstatsoft.org/v50/i01/.

See Also

HMDdata.

Examples

Run this code
## "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