dateSeq | R Documentation |
Creates a sequence of dates or times.
dateSeq(from, to, length.out, by)
from |
starting date. |
to |
end date. Can be given instead of |
by |
character string, increment of the sequence. One of " |
lenght.out |
desired length of the sequence. A non-negative integer. Can be given instead of |
Depending on the value of by
, there are some requirements for the other arguments.
For "min
" and "hour
" the format of from
and to
should be a correct format for the function as.POSIXct
.
For "day
" and "week
" the format of from
and to
should be a correct format for the function as.Date
.
For "month
" the format of from
and to
should be a correct format for the function yearmon
.
For "quarter
" the format of from
and to
should be a correct format for the function yearqtr
.
A vector of dates.
as.POSIXct
, as.Date
, yearmon
, yearqtr
.
dateSeq(from = "2022-01", length.out = 24, by = "month") dateSeq(from = "2022-01-01", to = "2023-12", by = "month") dateSeq(from = "2022-01-03", length.out = 12, by = "week") dateSeq(from = "2022-01-03", to = "2022-03-21", by = "week") #An example extracting the times of AirPassengers dateSeq(from = time(AirPassengers)[1], length.out = length(AirPassengers), by = "month")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.