Description Usage Arguments Value Note Author(s) Examples
Convert integer/numeric ages, or dates (of birth) to a factor of standard age
groups, with presentable labels, ordered from youngest to oldest. The default
provides the 'standard' age groups used by much of the market research
industry. Custom age breaks can also be used, by passing a vector to the
breaks
argument.
1 2 |
x |
A |
breaks |
a A |
right |
Passed internally to |
... |
Additional arguments passed to |
factor
age groups
This function does not round ages, and so the common cultural/numerical interpretation of age works with decimal numbers. For example someone who has existed for 17.999 years is said to be 17 years old. The function (with default settings) will process 17 and 17.9999 in the same fashion.
Brendan Rocks rocks.brendan@gmail.com
1 2 3 4 5 6 7 8 9 10 11 12 13 | data(test_data)
# A 'rough and ready' way of calculating ages
test_data$age <- as.numeric(Sys.Date() - test_data$dob) /365
# Let's put those ages into groups
test_data$age_group <- age_breaks(test_data$age)
# Hooray!
table(test_data$age_group)
# We could do the above by simply passing in the dates of birth
test_data$age_group <- age_breaks(test_data$dob)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.