calendar_period: Calendar periods

Description Usage Arguments Details Value See Also

View source: R/calendar_periods.R

Description

Create a function to turn dates into calendar periods.

Usage

1
calendar_period(period = c('month', 'quarter', 'year'), start.mon = month.name)

Arguments

period

One of 'month' (default), 'quarter', or 'year'.

start.mon

In which month does a calendar year start (default is January)?

Details

This function creates a simple wrapper for cut.POSIXt. By default it turns a date into the first day in a given calendar period, essentially rounding down dates.

Non-standard calendar periods that do not start in January (e.g., fiscal years) can be constructed by choosing a different starting month for a year with start.mon.

This function is an alternative to some useful features in 'zoo'. It is essentially creates a drop-in replacement for as.Date(as.yearmon(as.Date)). When dates are clustered, as in most time-series application, performance is about the same as the 'zoo' equivalent. Performance can be much faster when working with microdata, and is usually slower when working with few dates that are spread out.

Value

A function.

See Also

year month / year quarter / year for the important cases.


ppd-dpp/calpr documentation built on June 25, 2020, 12:09 a.m.