Maps an individual age to a categorical age-group label.
Value
A character string containing the matching age-group label.
Returns NA if no matching age group can be found.
Details
Age groups are specified using either:
Closed-open intervals of the form
"lower-upper".Open-ended intervals of the form
"lower+".
Examples:
"0-15"
"15-25"
"25-45"
"45-65"
"65+"This function is useful when converting continuous age information into the categorical age-group formats commonly used in contingency tables and marginal distributions.
Age groups are interpreted as:
"a-b"Ages greater than or equal to
aand strictly less thanb."a+"Ages greater than or equal to
a.
For example:
age_to_age_group(
20,
c(
"0-15",
"15-25",
"25-45"
)
)returns:
"15-25"