time_shift.Rd
time_shift
adds seconds, minutes, hours, days, weeks, months, quarters or
years to dates.
time_shift(x, by = NULL)
x |
|
---|---|
by | integer or character, either the number of shifting periods (integer), or an absolute amount of time (character). See details. |
an object of class Date
If by
is character, the time stamp is shifted by a specific amount of time.
This can be one of "sec"
, "min"
, "hour"
, "day"
, "week"
,
"month"
, "quarter" or
"year", or an abbreviation, optionally preceded by
a (positive or negative) integer and a space, or followed by plural "s". This
is passed to base::seq.Date()
. This does not require the series to be
regular.
ts_frequency()
for standard aggregation.
#> [1] "1950-03-01" "1950-04-01" "1950-05-01" "1950-06-01" "1950-07-01" #> [6] "1950-08-01"head(time_shift(ap.time, "7 week"))#> [1] "1949-02-19" "1949-03-19" "1949-04-19" "1949-05-19" "1949-06-19" #> [6] "1949-07-19"head(time_shift(ap.time, "-1 month"))#> [1] "1948-12-01" "1949-01-01" "1949-02-01" "1949-03-01" "1949-04-01" #> [6] "1949-05-01"#> [1] "1979-12-02"#> [1] "1979-12-01 00:59:46 CET"#> [1] "1978-12-01"#> mdeaths fdeaths #> Dec 1979 1341 574