Skip to contents

Creates a new age-group variable from an existing age variable using one of several predefined classification schemes.

Usage

add_recoded_age(
  data_df,
  new_1L_chr = "AgeGroup",
  old_1L_chr = "AGEP",
  type_1L_chr = c("one", "two", "three", "four", "five", "six", "seven", "eight", "nine",
    "ten", "eleven")
)

Arguments

data_df

A data frame or data.table.

new_1L_chr

Name of the new age-group variable to create. Defaults to "AgeGroup".

old_1L_chr

Name of the source age variable. Defaults to "AGEP".

type_1L_chr

Character scalar specifying the age classification scheme to apply. One of:

one

Five-year age groups beginning at age 0.

two

Broad demographic age groups.

three

Burden-of-disease age groups.

four

Mental-health modelling age groups.

five

Alternative broad age grouping.

six

Standard five-year age groups with 65+ aggregated.

seven

Child, youth, adult and older-adult grouping.

eight

Three broad adult age bands.

nine

Extended life-course grouping.

ten

Detailed five-year age groups.

eleven

ERP-style ABS age group coding.

Value

The input object with an additional age-group variable.

Details

Classification schemes correspond to commonly used age aggregations in Australian demographic, health and burden-of-disease reporting.

Examples

ages_df <- data.frame(
  Age = c("25 years", "45 years", "70 years")
)

add_recoded_age(
  ages_df,
  old_1L_chr = "Age",
  new_1L_chr = "AgeGroup4",
  type_1L_chr = "four"
)
#>        Age AgeGroup4
#> 1 25 years  25 years
#> 2 45 years  45 years
#> 3 70 years  70 years