warp_change() detects changes at the period level. It returns the
locations of the value just before a change. The location of the last
value in x is always returned at the end.
Usage
warp_change(x, period, every = 1L, origin = NULL)
Arguments
x
[Date / POSIXct / POSIXlt]
A date time vector.
period
[character(1)]
A string defining the period to group by. Valid inputs can be roughly
broken into:
"year", "quarter", "month", "week", "day"
"hour", "minute", "second", "millisecond"
"yweek", "mweek"
"yday", "mday"
every
[positive integer(1)]
The number of periods to group together.
For example, if the period was set to "year" with an every value of 2,
then the years 1970 and 1971 would be placed in the same group.
origin
[Date(1) / POSIXct(1) / POSIXlt(1) / NULL]
The reference date time value. The default when left as NULL is the
epoch time of 1970-01-01 00:00:00, in the time zone of the index.
This is generally used to define the anchor time to count from, which is
relevant when the every value is > 1.
Value
A double vector of locations right before a change.
# NOT RUN {x <- as.Date("2019-01-01") + 0:5warp_change(x, period = "day", every = 2)
warp_change(x, period = "day", every = 2, origin = as.Date("2019-01-01"))
# }