Convert an age (in years) to a bracket.

get_age_bracket(x)

Arguments

x

Age in years (vector)

Value

Ordered factor indicating the age bracket

Examples

get_age_bracket(21)
#> [1] 20-29 #> Levels: 0-19 < 20-29 < 30-39 < 40-49 < 50-59 < 60-69 < 70-79 < 80+
get_age_bracket(c(10, 20, 21, 25, 29, 30, 31, 39, 40, 41))
#> [1] 0-19 20-29 20-29 20-29 20-29 30-39 30-39 30-39 40-49 40-49 #> Levels: 0-19 < 20-29 < 30-39 < 40-49 < 50-59 < 60-69 < 70-79 < 80+