seq.Date {base}R Documentation

Generate Regular Sequences of Dates

Description

The method for seq for objects of class "Date" representing calendar dates.

Usage

## S3 method for class 'Date'
seq(from, to, by, length.out = NULL, along.with = NULL, ...)

Arguments

from

starting date; optional.

to

end date; optional.

by

increment of the sequence; optional. See ‘Details’.

length.out

integer, optional. Desired length of the sequence.

along.with

optional; take the length from the length of this argument.

...

arguments passed to or from other methods.

Details

by can be specified in several ways.

Value

A vector of class "Date". Type "integer" is often preserved on purpose, saving object.size.

See Also

Date

Examples

## first days of years
seq(as.Date("1910/1/1"), as.Date("1999/1/1"), "years")
## by month
seq(as.Date("2000/1/1"), by = "month", length.out = 12)
## quarters
seq(as.Date("2000/1/1"), as.Date("2003/1/1"), by = "quarter")

## 3-week period ending on a fixed date
seq(to = as.Date("2024-06-18"), by = "day", length.out = 21)

## find all 7th of the month _strictly_ inside two dates, the last being a 7th.
st <- as.Date("1998-12-17")
en <- as.Date("2000-1-7")
ll <- seq(en, st, by = "-1 month")
rev(ll[st < ll & ll < en])

## can abbreviate 'month' to 'm':
identical(seq(st, en, by = "m"),
          seq(st, en, by = "1 month"))

[Package base version 4.5.0 Index]