Detect changes in a date time vector
warp_change()
detects changes at the period
level.
If last = TRUE
, it returns locations of the last value before a change,
and the last location in x
is always included. Additionally, if
endpoint = TRUE
, the first location in x
will be included.
If last = FALSE
, it returns locations of the first value after a change,
and the first location in x
is always included. Additionally, if
endpoint = TRUE
, the last location in x
will be included.
warp_change( x, period, ..., every = 1L, origin = NULL, last = TRUE, endpoint = FALSE )
x |
A date time vector. |
period |
A string defining the period to group by. Valid inputs can be roughly broken into:
|
... |
These dots are for future extensions and must be empty. |
every |
The number of periods to group together. For example, if the period was set to |
origin |
The reference date time value. The default when left as This is generally used to define the anchor time to count from, which is
relevant when the every value is |
last |
If If |
endpoint |
If If If |
A double vector of locations.
x <- as.Date("2019-01-01") + 0:5 x # Last location before a change, last location of `x` is always included warp_change(x, period = "yday", every = 2, last = TRUE) # Also include first location warp_change(x, period = "yday", every = 2, last = TRUE, endpoint = TRUE) # First location after a change, first location of `x` is always included warp_change(x, period = "yday", every = 2, last = FALSE) # Also include last location warp_change(x, period = "yday", every = 2, last = FALSE, endpoint = TRUE)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.