Description Usage Arguments Details Value Examples
This is the main function in this package. It will convert one or more years to the corresponding generation. Generation names and years are taken from Howe & Strauss' generational theory.
1 2 3 4 5 6 7 8 | generations(
yob,
full_names = FALSE,
years = FALSE,
years_sep = " ",
years_range_sep = "–",
as_factor = TRUE
)
|
yob |
a vector of integers. Currently, integers are the only accepted input, so characters and date types must be converted first. |
full_names |
logical. If |
years |
logical. Should the year range be included in the output? Useful
for printing, plotting, or otherwise displaying. For example, "Gen X" becomes
"Gen X (1964–1983)". |
years_sep |
a string. If |
years_range_sep |
a string. If |
as_factor |
logical. Should the vector be returned as a factor? If so,
the levels will be chronological order (oldest generation first). If not, it
will be returned as a character vector. |
Note that labels are included for years between 1435 and 2030. Anything outside
of that range will return NA
.
a vector
1 2 3 4 5 6 7 8 | # Generate some sample data
yobs <- sort(floor(runif(10, 1880, 2020)))
# Convert to the generations
generations(yobs)
generations(yobs, full_names = TRUE)
generations(yobs, full_names = TRUE, years = TRUE)
generations(yobs, years = TRUE, years_range_sep = " to ")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.