Standardizes age groups to match seer_std_ages. Adds an age_group
column,
or overwites the existing age_group
column if present. The age_var
column
can be either an actual age or an age group. If the column is numeric, it
assumed to be an actual age, otherwise if it contains any non-numeric
characters it is assumed to be an age group that will be expanded using
separate_age_groups()
. If multiple standardized age groups match a given age,
the function will throw an error.
standardize_age_groups(data = NULL, age_group = age_group, std_age_groups = fcds_const("age_group"), ...)
data | A data frame. |
---|---|
age_group | The column containing age or age group. This column will be
overwritten if named |
std_age_groups | Standard age groups, in the desired order. |
... | Arguments passed on to
|
format_age_groups()
for the specification of the age group label
format and to convert age boundaries into age group labels.
Other age processors: complete_age_groups
,
filter_age_groups
,
format_age_groups
,
recode_age_groups
,
separate_age_groups
dplyr::tibble( id = 1:4, age_group = c("0 - 4", "10-14", "65-69", "85+") ) %>% standardize_age_groups()#> # A tibble: 4 x 2 #> id age_group #> <int> <ord> #> 1 1 0 - 4 #> 2 2 10 - 14 #> 3 3 65 - 69 #> 4 4 85+