The R Project SVN R

Rev

Rev 71883 | Rev 87533 | Go to most recent revision | 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
71883 ripley 3
% Copyright 1995-2017 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{
30912 ripley 10
  The method for \code{\link{seq}} for date-time 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{
55555 ripley 16
  \item{from}{starting date.  Required.}
17
  \item{to}{end date.  Optional.}
18
  \item{by}{increment of the sequence.  Optional.  See \sQuote{Details}.}
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.
27
    \item A object of class \code{\link{difftime}}
28
    \item A character string, containing one of \code{"sec"},
17734 ripley 29
    \code{"min"}, \code{"hour"}, \code{"day"}, \code{"DSTday"},
64957 ripley 30
    \code{"week"}, \code{"month"}, \code{"quarter"} or \code{"year"}.
31
    This can optionally be preceded by a (positive or negative) integer
32
    and a space, or followed by \code{"s"}.
13806 ripley 33
  }
17734 ripley 34
  The difference between \code{"day"} and \code{"DSTday"} is that the
35
  former ignores changes to/from daylight savings time and the latter takes
74363 maechler 36
  the same clock time each day.  \code{"week"} ignores DST (it is a
37
  period of 144 hours), but \code{"7 DSTdays"} can be used as an
38
  alternative.  \code{"month"} and \code{"year"} allow for DST.
34344 ripley 39
 
64321 ripley 40
  The \link{time zone} of the result is taken from \code{from}: remember
41
  that GMT means UTC (and not the time zone of Greenwich, England) and so
51360 ripley 42
  does not have daylight savings time.
38789 ripley 43
 
44
  Using \code{"month"} first advances the month without changing the
45
  day: if this results in an invalid day of the month, it is counted
46
  forward into the next month: see the examples.
13806 ripley 47
}
48
\value{
49
  A vector of class \code{"POSIXct"}.
50
}
64957 ripley 51
 
13806 ripley 52
\seealso{\code{\link{DateTimeClasses}}}
53
 
54
\examples{
17734 ripley 55
## first days of years
17247 luke 56
seq(ISOdate(1910,1,1), ISOdate(1999,1,1), "years")
13806 ripley 57
## by month
44738 hornik 58
seq(ISOdate(2000,1,1), by = "month", length.out = 12)
59
seq(ISOdate(2000,1,31), by = "month", length.out = 4)
13806 ripley 60
## quarters
64957 ripley 61
seq(ISOdate(1990,1,1), ISOdate(2000,1,1), by = "quarter") # or "3 months"
64321 ripley 62
## days vs DSTdays: use c() to lose the time zone.
44738 hornik 63
seq(c(ISOdate(2000,3,20)), by = "day", length.out = 10)
64
seq(c(ISOdate(2000,3,20)), by = "DSTday", length.out = 10)
65
seq(c(ISOdate(2000,3,20)), by = "7 DSTdays", length.out = 4)
13806 ripley 66
}
67
\keyword{manip}
68
\keyword{chron}