Construct Age Group Column to Dataset
construct_age_group.Rd
This function takes a dataset and adds a new column that contains age groups.
Examples
df <- data.frame(id = 1:10, age = c(23, 45, 34, 56, 29, 12, 67, 44, 33, 55))
new_df <- construct_age_group(df, age_col = "age", group_size = 10)
print(new_df)
#> id age fert_age_grp
#> 1 1 23 20-29
#> 2 2 45 40-49
#> 3 3 34 30-39
#> 4 4 56 50-59
#> 5 5 29 20-29
#> 6 6 12 10-19
#> 7 7 67 60-69
#> 8 8 44 40-49
#> 9 9 33 30-39
#> 10 10 55 50-59