Generate Regular Sequences of Times (original) (raw)

seq.POSIXt {base} R Documentation

Description

The method for [seq](../../base/help/seq.html) for date-time ("[POSIXt](../../base/help/POSIXt.html)") classes.

Usage

## S3 method for class 'POSIXt'
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 take the length from the length of this argument.
... arguments passed to or from other methods.

Details

by can be specified in several ways.

The difference between "day" and "DSTday" is that the former ignores changes to/from daylight savings time and the latter takes the same clock time each day. "week" ignores DST (it is a period of 144 hours), but "7 DSTdays" can be used as an alternative. "month" and "year" allow for DST.

The time zone of the result is taken from from unless onlyto is provided: remember that GMT means UTC (and not the time zone of Greenwich, England) and so does not have daylight savings time.

Using "month" first advances the month without changing the day: if this results in an invalid day of the month, it is counted forward into the next month: see the examples.

Value

A vector of class "POSIXct", internally of type"[double](../../base/help/double.html)" or "[integer](../../base/help/integer.html)".

See Also

[DateTimeClasses](../../base/help/DateTimeClasses.html)

Examples

## first days of years
seq(ISOdate(1910,1,1), ISOdate(1999,1,1), "years")
## by month
seq(ISOdate(2000,1,1), by = "month", length.out = 12)
seq(ISOdate(2000,1,31), by = "month", length.out = 4)
## quarters
seq(ISOdate(1990,1,1), ISOdate(2000,1,1), by = "quarter") # or "3 months"
## days vs DSTdays: use c() to lose the time zone.
seq(c(ISOdate(2000,3,20)), by = "day", length.out = 10)
seq(c(ISOdate(2000,3,20)), by = "DSTday", length.out = 10)
seq(c(ISOdate(2000,3,20)), by = "7 DSTdays", length.out = 4)

## 24-hour period ending at a fixed time
seq(to = ISOdate(2024,1,2, 3,4,5), by = "hour", length.out = 24)

[Package _base_ version 4.6.0 Index]