Categorize a person's age
categorize_age.Rd
A helper function to create age group categories from a precomputed numeric age variable.
categorize_age()
uses the cut()
function to create right-closed
intervals by default, i.e. "(a,b]
", of age groups by decade labeled as:
'0-10', '10-20', '20-30', '30-40', '40-50', '50-60', '60-70', '70-80', '80+'.
A patient who is 30 years 47 days old will be in the '30-40' group.
Examples
if (FALSE) { # \dontrun{
ds$person %>%
dplyr::left_join(get_person_age(ds)) %>% # Procompute `age` variable, defaults to enrollment
mutate(age_category = categorize_age(age))
} # }