format_period_year: Create consistent, complete single-year periods

Description Usage Arguments Details Value See Also Examples

View source: R/format_period.R

Description

Given a vector of period labels, create a factor that contains levels for the earliest and latest periods in x, and for all periods in between.

Usage

1

Arguments

x

A vector of single-year period labels.

Details

The elements of x must be single-year labels such as "2001" or "2055". x cannot contain multi-year intervals such as "2000-2005" or "<2020".

If x contains NA, then the levels of the factor created by format_period_year also contain NA.

Value

A factor with the same length as x.

See Also

Other functions for reformating period labels are

date_to_period_year creates single-year periods from dates.

Examples

1
2
3
4
5
6
## the 'levels' contain all values from
## '2000' to '2010', even when these do not
## appear in the data
format_period_year(x = c("2000", "2010"))

format_period_year(x = c("2000", "2005", NA, "2004"))

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