seqmondate-methods: Methods to Generate Date Sequences

seqmondate-methodsR Documentation

Methods to Generate Date Sequences

Description

Methods to generate date sequences. This is essentially a wrapper for seq.mondate that requires from and to to be of the same class – when both are specified – and returns a sequence of that class. The primary purpose is to generate sequences in units of "months" (the default value of the unnamed argument by).

Arguments

from
to

objects of class mondate, Date, POSIXlt, or POSIXct. May be "missing". If both present, must be of the same class.

...

optional arguments passed to seq.mondate

Value

A sequence of the same class as from\to.

Methods

signature(from = "mondate", to = "mondate", ...)
signature(from = "Date", to = "Date", ...)
signature(from = "POSIXlt", to = "POSIXlt", ...)
signature(from = "POSIXct", to = "POSIXct", ...)
signature(from = "ANY", to = "ANY", ...)

Examples

# 13 month-end dates starting with the end of 2014 and 
#   ending with the end of 2015
seqmondate(mondate.ymd(2014), mondate.ymd(2015))

# In most situations, seq.Date and seqmondate return identical sequences,
# as when 'from' is at the beginning of the month.
s1 <- seq(as.Date("2015-01-01"), as.Date("2015-12-01"), by = "month")
s2 <- seqmondate(as.Date("2015-01-01"), as.Date("2015-12-01"))
stopifnot(identical(s1, s2))

# But when 'from' is near the end of a long month, seq.Date, seq.POSIXct, etc
# can step into subsequent months (as documented in ?seq.POSIXt).
seq(as.POSIXct("2015-01-31"), by = "month", length.out = 12)
# ... contrasted with ...
seqmondate(as.POSIXct("2015-01-31"), by = "month", length.out = 12)

chiefmurph/mondate documentation built on Aug. 29, 2022, 4:13 p.m.