Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

calendar-periods

Rolling periods


Description

Returns start and end dates for a rolling periods

Usage

periods(x, period = "12m", by = "1m", offset = "0d")
periodicallyRolling(x, period = "52w", by = "4w", offset = "0d")
monthlyRolling(x, period = "12m", by = "1m")

Arguments

x

an object of class timeDate.

period

a span string, consisting of a length integer and a unit value, e.g. "52w" for 52 weeks.

by

a span string, consisting of a length integer and a unit value, e.g. "4w" for 4 weeks.

offset

a span string, consisting of a length integer and a unit value, e.g. "0d" for no offset.

Details

Periodically Rolling - Allowed unit values are "m" for 4 weeks, "w" for weeks, "d" for days, "H" for hours, "M" for minutes, and "S" for seconds.

Monthly Calendar Rolling - The only allowed allowed unit value is "m" for monthly periods. Express a quarterly period by "3m", a semester by "6m", a year by "12m" etc.

Examples

## Create Time Sequence -
   x <- timeSequence(from = "2001-01-01", to = "2009-01-01", by = "day")

## Generate Periods -
   periods(x, "12m", "1m")
   periods(x, "52w", "4w")

## Roll Periodically -
   periodicallyRolling(x)

## Roll Monthly -
   monthlyRolling(x)

timeDate

Rmetrics - Chronological and Calendar Objects

v3043.102
GPL (>= 2)
Authors
Diethelm Wuertz [aut], Tobias Setz [cre], Yohan Chalabi [ctb], Martin Maechler [ctb], Joe W. Byers [ctb]
Initial release
2018-02-21

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.