Parse upper bounds from age class labels
get_age_upper_bounds.RdExtract numeric upper bounds from age class labels for binning or recoding age variables. Use when creating new age classes from labeled data for tabulation or reporting.
Details
Detects labels indicating minimum age (e.g., 'less than', 'under').
Extracts trailing numeric value from each label.
Adjusts minimum class to be exclusive (subtracts 1).
Returns a numeric vector; does not modify by reference.
Assumes labels are character and contain numeric bounds; errors if not.
See also
value_labels
Other recoding utilities:
get_income_bounds(),
get_max_acs_income_bin(),
get_max_income_bin(),
get_max_survey_income_bin()
Examples
labels <- c('Under 5', '5-9', '10-14', '15+')
get_age_upper_bounds(labels)
#> [1] 4 9 14 NA