dot-k_by: Converts k and lag from time-unit-interval to int

.k_byR Documentation

Converts k and lag from time-unit-interval to int

Description

Converts k and lag from time-unit-interval to int

Usage

.k_by(k, idx, param)

Arguments

k

(integer vector or single value)
Denoting size of the running window. If k is a single value then window size is constant for all elements, otherwise if length(k) == length(x) different window size for each element. One can also specify k in the same way as by argument in base::seq.POSIXt(). See 'Specifying time-intervals' in details section.

idx

(integer, Date, POSIXt)
Optional integer vector containing sorted (ascending) index of observation. By default idx is index incremented by one. User can provide index with varying increment and with duplicated values. If specified then k and lag are depending on idx. Length of idx have to be equal of length x.

param

name of the parameter to be printed in error message

Examples

k <- "1 month"
idx <- seq(
  as.POSIXct("2019-01-01 03:02:01"),
  as.POSIXct("2020-01-01 03:02:01"),
  by = "month"
)
k_difftime <- runner:::.k_by(k, idx, param = "k")
idx - k_difftime

runner documentation built on May 29, 2024, 10:22 a.m.