age <- c(54, 7, 77, 1, 26, 101)
create_age_groups(age)
create_age_groups(age, from = 0, to = 80, by = 10)
# Final group may start below 'to'
create_age_groups(age, from = 0, to = 65, by = 10)
# To get the output as a factor:
create_age_groups(age, as_factor = TRUE)
Run the code above in your browser using DataLab