span_around {padr} | R Documentation |
Span an equally spaced vector around a datetime variable
Description
Span a vector of specified interval around a variable of class Date
,
POSIXct
, or POSIXlt
..
Usage
span_around(x, interval, start_shift = NULL, end_shift = start_shift)
Arguments
x |
A vector of class |
interval |
Character, specifying the desired interval. |
start_shift |
Character, indicating the time to shift back from the first observation. |
end_shift |
Character, indicating the time to shift forward from the last observation. |
Details
Note that use of the start_shift
and end_shift
arguments change the entire spanning when they are not in line with
the interval. It is not checked for.
Value
A datetime vector, with the first observation smaller or equal than
min(x)
and the last observation larger or equal than max(x)
.
Spaces between points are equal to interval
.
Examples
span_around(coffee$time_stamp, "hour")
span_around(coffee$time_stamp, "hour", end_shift = "2 hour")
span_around(coffee$time_stamp, "2 day")
span_around(coffee$time_stamp, "2 day", start_shift = "2 day")
span_around(emergency$time_stamp, "week")
span_around(emergency$time_stamp, "2 month")
[Package padr version 0.6.2 Index]