Description Usage Arguments Details Value See Also Examples
View source: R/format_period.R
Given a vector of period labels, create a
factor
that contains levels for all periods
defined by breaks
. format_period_custom
is the most flexible
of the format_period
functions
in that the periods can have any combination of widths.
1 | format_period_custom(x, breaks, month_start = "Jan", label_year_start = TRUE)
|
x |
A vector of period labels. |
breaks |
A vector of strictly increasing integer values. |
month_start |
An element of |
label_year_start |
Logical. Whether to label a period
by the calendar year at the beginning of the period
or the calendar year at the end. Defaults to |
The elements of x
can be
single-year labels such as "2000"
and "1975"
, multi-year labels
such as "1950-1960"
and "2020-2025"
,
or a mixture of the two.
x
cannot contain open intervals
such as "<2020"
.
If x
contains NA
, then the
levels of the factor created by format_period_custom
also contain NA
.
A factor with the same length as
x
.
Other functions for reformating period labels are
format_period_year
format_period_multi
format_period_quarter
format_period_month
date_to_period_year
creates
periods from dates.
1 2 3 4 5 | format_period_custom(x = c("2000-2001", "2004", "2005-2010", "1996-1998"),
breaks = c(1990, 2000, 2020))
format_period_custom(x = c("2000-2001", "2004", "2005-2010", "1996-1998"),
breaks = c(1995, 2005, 2010, 2020))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.