Skip to contents

put timestamps onto a coarser grid

Usage

coarsen_time(x, resolution = 1)

Arguments

x

numeric timestamps, or anything [as.numeric()] turns into them (a POSIXct becomes seconds since the epoch, so `resolution` is then in seconds)

resolution

width of one bin, in the units of `x`. `1` leaves `x` alone up to flooring; `24` on hourly data gives days.

Value

an integer-valued numeric vector of bin indices

Examples

coarsen_time(c(0, 1, 5, 23, 24, 25), resolution = 12)
#> [1] 0 0 0 1 2 2