Learn R Programming

statar (version 0.1.1)

elapsed: Elapsed dates (weekly, monthly, quarterly)

Description

Elapsed dates (weekly, monthly, quarterly)

Usage

as.quarterly(x)

as.monthly(x)

as.weekly(x)

is.quarterly(x)

is.monthly(x)

is.weekly(x)

Arguments

x
a vector

Details

Weekly, monthly and quarterly dates are stored as integers, representing the number of elapsed calendar periods since 01/01/1970. This allows to use arithmetic on dates other than daily, ie date + 1 adds one period rather than one day. Moreover, these dates are printed in a way that fits their frequency (YYYqq, YYYmMM, YYYwWW).

Methods to convert from and to Dates or POSIXlt are provided. In particular, you may use lubridate week month and year to extract information from elapsed dates.

Examples

Run this code
library(lubridate)
date <- mdy(c("04/03/1992", "01/04/1992", "03/15/1992"))
datem <- as.monthly(date)
is.monthly(datem)
as.weekly(date)
as.quarterly(date)
as.character(datem)
datem + 1
lag(c(1, 2, 3), n = 1, along_with = datem)
seq(datem[1], datem[2])
as.Date(datem)
as.POSIXlt(datem)
as.POSIXct(datem)
week(datem)

Run the code above in your browser using DataLab