Description Usage Arguments Details Value See Also Examples
Change one-year period or cohort labels from using the calendar year at the start to using the calendar year at the end, or vice versa.
1 2 3 | flip_to_start(x, month_start = "Jan")
flip_to_end(x, month_start = "Jan")
|
x |
A vector of period or cohort labels that are single-year or open on the left. |
month_start |
An element of |
As discussed in date_to_period_year
and date_to_cohort_year
, single-year
labels are ambiguous. The label "2020"
, for instance,
could refer to many different sets of dates, depending on
the starting month and on whether the 2020 refers to
the calendar year at the start of the period or cohort,
or the calendar year at the end.
Converting between calendar-year-at-end conventions
and calendar-year-at-start conventions is error-prone.
flip_to_end
and flip_to_start
try to make the process a little easer. The functions are
used as follows
Current labels | Desired labels | Function to use |
Use calendar year at start | Use calendar year at end | flip_to_end |
Use calendar year at end | Use calendar year at start | flip_to_start |
If month_start
is "Jan"
(so that
the labels are the same under both conventions)
flip_to_end
and flip_to_start
returns the original labels.
A vector with the same length as x
.
date_to_period_year
,
date_to_cohort_year
,
format_period_year
,
format_cohort_year
1 2 3 4 5 6 7 8 9 10 11 12 | ## currently using calendar year at start of period
flip_to_end(x = c("2001", "2005"),
month_start = "Jul")
## currently using calendar year at end of period
flip_to_end(x = c("2001", "2005"),
month_start = "Jul")
## periods start in January, so changing labelling
## rule has no effect
flip_to_end(x = c("2001", "2005"),
month_start = "Jan")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.