elapsed | R Documentation |
Elapsed dates (monthly, quarterly)
as.quarterly(x)
is.quarterly(x)
as.monthly(x)
is.monthly(x)
x |
a vector |
Monthly and quarterly dates are stored as integers, representing the number of elapsed calendar periods since 01/01/1970. As yearmonth
and yearqtr
the package zoo
, these dates are printed in a way that fits their frequency (YYY
qq
, YYY
mMM
). The only difference is that, monthly
, and quarterly
are integers, which removes issues due to floating points (particularly important when merging). This also allows to use arithmetic on perios, ie date
+ 1 adds one period rather than one day.
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.
library(lubridate)
library(dplyr)
date <- mdy(c("04/03/1992", "01/04/1992", "03/15/1992"))
datem <- as.monthly(date)
is.monthly(datem)
as.quarterly(date)
as.character(datem)
datem + 1
df <- tibble(datem)
# filter(df, month(datem) == 1)
seq(datem[1], datem[2])
as.Date(datem)
as.POSIXlt(datem)
as.POSIXct(datem)
week(datem)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.