Period: Convert date objects to character strings

View source: R/period.R

PeriodR Documentation

Convert date objects to character strings

Description

Converts a date into a character.

Usage

Period(x, by, anchor.date = as.Date("1970-01-01"), long.name = FALSE, ...)

Arguments

x

The date.

by

The period used in the conversion (e.g., "week", "year"). Special cases include:

  • "quarter", which provides the month for the quarter as YYYY-MM

  • "nice.quarter", which provides the quarter in the form Q1 2022

  • "2-week", "4-week" , etc which provides multi-week periods labeled with the first date in the corresponding period, e.g. "2 weeks commencing 2022-07-03". Requires to use to specify the anchor.date argument as a point of reference.

anchor.date

Supply a Date value to disambiguate multi-week periods. When asking for two-week periods, four week-periods, etc, for a given value of x, the choice is ambiguous. For example, when wanting the two-week period for "2022-07-04", should the period cover the 2 weeks commencing "2022-07-03" or the two weeks commencing "2022-06-26"? All multi-week periods will be determined relative to the first day in the week which contains the anchor.date. Note that this function uses lubridate, where the default week start day is Sunday.

long.name

Logical; if TRUE the output string is more verbose: months will be their full names, quarters will be written as "Quarter", and "week commencing" will be added when code'week" is "week".

...

Additional arguments passed to lubridate


NumbersInternational/flipTime documentation built on Feb. 26, 2024, 6:44 a.m.