## S3 method for class 'Date': seq(from, to, by, length.out = NULL, along.with = NULL, ...) ## S3 method for class 'POSIXt': seq(from, to, by, length.out = NULL, along.with = NULL, ...)
from | a Date or POSIXt object representing the starting date. Required. |
to | a Date or POSIXt object representing the ending date. |
by |
one of the following specifying the spacing between successive values in the sequence:
|
length.out | an integer value specifying the length of the sequence. It is ignored if along.with is given. A non-integer input is rounded to integer by the ceiling function. |
along.with | an object, if specified, whose length (instead of length.out) is used as the length of the sequence. |
... | additional arguments. |
Example R> seq(as.Date("2000-01-31"), by = "months", length = 12) [1] "2000-01-31" "2000-03-02" "2000-03-31" "2000-05-01" [5] "2000-05-31" "2000-07-01" "2000-07-31" "2000-08-31" [9] "2000-10-01" "2000-10-31" "2000-12-01" "2000-12-31"
TERR> seq(as.Date("2000-01-31"), by = "months", length = 12) [1] "2000-01-31" "2000-02-29" "2000-03-31" "2000-04-30" [5] "2000-05-31" "2000-06-30" "2000-07-31" "2000-08-31" [9] "2000-09-30" "2000-10-31" "2000-11-30" "2000-12-31"
## seq.Date d1 <- Sys.Date() d2 <- d1 + 100seq(d1, d2, by = 6) seq(d1, d2, by = "6 days") seq(d1, d2, by = .difftime(6, "days"))
seq(d1, d2, by = "month") seq(d1, d2, by = "2 months") seq(d2, d1, by = "-1 month")
seq(d1, d2, length.out = 4) seq(d1, d2, along.with = 1:4) seq(d1, by = 6, length.out = 4)
## seq.POSIXt ## The start date-time of DST in USA 2011 is: 2011-03-13 2:00AM from <- as.POSIXct("2011-03-12 20:23:14", tz = "US/Pacific") to <- as.POSIXct("2011-03-15 20:23:14", tz = "US/Pacific") seq(from, to, by = "days") seq(from, to, by = "DSTdays")
from <- as.POSIXlt("2011-03-12 20:23:14", tz = "US/Pacific") to <- as.POSIXlt("2011-03-15 20:23:14", tz = "US/Pacific") seq(from, to, by = "days") seq(from, to, by = "DSTdays")