I'm trying to create a bin that looks like "<18, 18-24, 25-34, 35-44, 45-54, 55-64, 65+". I'm able to create evenly spaced ranges (25-34, 35-44...65+) but I can't figure out how to add the first two ranges (<18, 18-24). Here's the code that I found:
age.cat <- function(x, lower = 0, upper, by = 10,
sep = "-", above.char = "+") {
labs <- c(paste(seq(lower, upper - by, by = by),
seq(lower + by - 1, upper - 1, by = by),
sep = sep),
paste(upper, above.char, sep = ""))
cut(floor(x), breaks = c(seq(lower, upper, by = by), Inf),
right = FALSE, labels = labs)
}
Any help would be much appreciated. Thanks