as_date_range_year: Convert non-ambiguous labels for one-year periods or cohorts

Description Usage Arguments Details Value See Also Examples

View source: R/as_date_range.R

Description

Convert standard labels for one-year periods such as "2020", "2001", or "<2005" to labels that give precise date ranges such as "[2020-01-01, 2020-12-31]", "[2001-10-01, 2002-10-01]", or "(-Inf, 2005-06-30]".

Usage

1
as_date_range_year(x, month_start = "Jan", label_year_start = TRUE)

Arguments

x

A vector of period or cohort labels.

month_start

An element of month.name, or month.abb. Each period or cohort starts on the first day of this month.

label_year_start

Whether to label a period by the calendar year at the beginning of the period or the calendar year at the end. Defaults to TRUE.

Details

The vector of period or cohort labels x is typically created using functions format_period_year or format_cohort_year.

Value

A factor the same length as x.

See Also

as_date_range_multi, as_date_range_custom, as_date_range_quarter, as_date_range_month

Examples

1
2
3
4
5
6
7
x <- c("<2010", "2010", "2011")
as_date_range_year(x)
as_date_range_year(x,
                   month_start = "Jul")
as_date_range_year(x,
                   month_start = "Jul",
                   label_year_start = FALSE)

johnrbryant/demprep documentation built on Dec. 31, 2021, 11:58 a.m.