The R Project SVN R

Rev

Rev 87537 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
42333 ripley 1
% File src/library/base/man/seq.POSIXt.Rd
68948 ripley 2
% Part of the R package, https://www.R-project.org
87502 maechler 3
% Copyright 1995-2025 R Core Team
42333 ripley 4
% Distributed under GPL 2 or later
5
 
13806 ripley 6
\name{seq.POSIXt}
56186 murdoch 7
\alias{seq.POSIXt}
50821 ripley 8
\title{Generate Regular Sequences of Times}
13806 ripley 9
\description{
87533 maechler 10
  The method for \code{\link{seq}} for date-time (\code{"\link{POSIXt}"}) classes.
13806 ripley 11
}
12
\usage{
30915 ripley 13
\method{seq}{POSIXt}(from, to, by, length.out = NULL, along.with = NULL, \dots)
13806 ripley 14
}
15
\arguments{
87502 maechler 16
  \item{from}{starting date; optional.}
17
  \item{to}{end date; optional.}
18
  \item{by}{increment of the sequence; optional.  See \sQuote{Details}.}
55555 ripley 19
  \item{length.out}{integer, optional.  Desired length of the sequence.}
13806 ripley 20
  \item{along.with}{take the length from the length of this argument.}
15458 ripley 21
  \item{\dots}{arguments passed to or from other methods.}
13806 ripley 22
}
23
\details{
24
  \code{by} can be specified in several ways.
25
  \itemize{
26
    \item A number, taken to be in seconds.
87502 maechler 27
    \item An object of class \code{\link{difftime}}
13806 ripley 28
    \item A character string, containing one of \code{"sec"},
17734 ripley 29
    \code{"min"}, \code{"hour"}, \code{"day"}, \code{"DSTday"},
87537 maechler 30
    \code{"week"}, \code{"month"}, \code{"quarter"} or \code{"year"}, or a
87569 hornik 31
    \code{\link{pmatch}()}able abbreviation of these.
64957 ripley 32
    This can optionally be preceded by a (positive or negative) integer
33
    and a space, or followed by \code{"s"}.
13806 ripley 34
  }
17734 ripley 35
  The difference between \code{"day"} and \code{"DSTday"} is that the
36
  former ignores changes to/from daylight savings time and the latter takes
74363 maechler 37
  the same clock time each day.  \code{"week"} ignores DST (it is a
38
  period of 144 hours), but \code{"7 DSTdays"} can be used as an
39
  alternative.  \code{"month"} and \code{"year"} allow for DST.
34344 ripley 40
 
87502 maechler 41
  The \link{time zone} of the result is taken from \code{from} unless only
42
  \code{to} is provided: remember that GMT means UTC (and not the time
43
  zone of Greenwich, England) and so does not have daylight savings time.
38789 ripley 44
 
45
  Using \code{"month"} first advances the month without changing the
46
  day: if this results in an invalid day of the month, it is counted
47
  forward into the next month: see the examples.
13806 ripley 48
}
49
\value{
87502 maechler 50
  A vector of class \code{"POSIXct"}, internally of type
51
  \code{"\link{double}"} or \code{"\link{integer}"}.
13806 ripley 52
}
64957 ripley 53
 
13806 ripley 54
\seealso{\code{\link{DateTimeClasses}}}
55
 
56
\examples{
17734 ripley 57
## first days of years
17247 luke 58
seq(ISOdate(1910,1,1), ISOdate(1999,1,1), "years")
13806 ripley 59
## by month
44738 hornik 60
seq(ISOdate(2000,1,1), by = "month", length.out = 12)
61
seq(ISOdate(2000,1,31), by = "month", length.out = 4)
13806 ripley 62
## quarters
64957 ripley 63
seq(ISOdate(1990,1,1), ISOdate(2000,1,1), by = "quarter") # or "3 months"
64321 ripley 64
## days vs DSTdays: use c() to lose the time zone.
44738 hornik 65
seq(c(ISOdate(2000,3,20)), by = "day", length.out = 10)
66
seq(c(ISOdate(2000,3,20)), by = "DSTday", length.out = 10)
67
seq(c(ISOdate(2000,3,20)), by = "7 DSTdays", length.out = 4)
87502 maechler 68
 
69
## 24-hour period ending at a fixed time
70
seq(to = ISOdate(2024,1,2, 3,4,5), by = "hour", length.out = 24)
13806 ripley 71
}
72
\keyword{manip}
73
\keyword{chron}