df <- data.frame(age = c(20, 28, 40, 55, 34, 10, 24, 55))
# Categorize without custom labels
category(df, var = age, level = c("10-25", "26-35", "36-50"))
# Categorize with custom labels
category(df, var = age, level = c("10-25", "26-35", "36-50"),
labels = c("young", "adult", "old"))
Run the code above in your browser using DataLab