Create age categories from a age vector

group_ages(age_column, age_group = 5, max_age = 100, return_chr = TRUE)

Arguments

age_column

a numeric vector of age to be categorized

age_group

Either a manually specified set of age groups OR an age interval to be divided up into equal parts. To manually specify the age range pass a vector of the right hand size of the age range. See example.

max_age

Maximum age in the age internal. For example if max_age is 100 then the function will calculate intervals all the way to 100+. This is ignored if a manual age range is specified.

return_chr

Should the function return a character or vector?

Value

A vector of age group the same length as the age_column

Examples

  c_vec <- seq(1:100)
  g_vec <- group_ages(c_vec)

  g_vec <- group_ages(c_vec, age_group = list(0:24, 25:50, 51:54, 55))