Skip to contents

Derives agegroupings according to how the parameters are set.

Usage

construct_age_groups(
  age_in_yrs_col,
  start_age,
  max_band,
  step_size,
  under_1 = TRUE
)

Arguments

age_in_yrs_col

name of the age in years variable used to derive group.

start_age

this is the lowest age for the first group, excluding < 1, if set to 5 then first group will be 01-04.

max_band

this is the final band in the age groupings e.g. 85+.

step_size

this is the width of each age band in years.

under_1

set to TRUE if you require an 'under one year old' group.

Value

returns an agegroup based on set parameters

Examples

data <- data %>%
mutate(AGEGROUP = construct_age_groups(AGEINYRS, start_age = 5, max_band = 95,
step_size = 5, under_1 = TRUE))
#> Error in data %>% mutate(AGEGROUP = construct_age_groups(AGEINYRS, start_age = 5,     max_band = 95, step_size = 5, under_1 = TRUE)): could not find function "%>%"
data <- data %>%
mutate(AGEGROUP = construct_age_groups(AGEINYRS, start_age = 30, max_band = 95,
step_size = 5, under_1 = FALSE))
#> Error in data %>% mutate(AGEGROUP = construct_age_groups(AGEINYRS, start_age = 30,     max_band = 95, step_size = 5, under_1 = FALSE)): could not find function "%>%"