format_age_lifetab: Create consistent, complete life table age group

Description Usage Arguments Details Value See Also Examples

View source: R/format_age.R

Description

Given a vector of age group labels, create a factor that contains levels for all ages between 0 and break_max, plus an open age group (ie an age group with no upper limit.) The age groups created by format_age_lifetab are the ones typically used in "abridged" life tables: "0", "1-4", "5-9", "10-14", and so on up to the highest age group, which is always open.

Usage

1
format_age_lifetab(x, break_max = 100)

Arguments

x

A vector of age group labels.

break_max

An integer or NULL. Defaults to 100.

Details

break_max is used to specify the oldest age group. If break_max is NULL, the oldest age group is derived from the data.

All age groups in x must fall within the intervals "0", "1-4", "5-9", ....

If x contains NA, then the levels of the factor created by format_age_lifetab also contain NA.

Value

A factor with the same length as x.

See Also

Other functions for reformating age group labels are

date_to_age_year calculates ages from dates.

Examples

1
2
3
4
5
format_age_lifetab(x = c("100+", "14", "1-4"))

## set oldest age group to 50+
format_age_lifetab(x = c("100+", "14", "1-4"),
                   break_max = 80)

johnrbryant/demprep documentation built on Dec. 31, 2021, 11:58 a.m.