consec_idx: This function iterates through values using a sliding window,...

View source: R/consec_idx.R

consec_idxR Documentation

This function iterates through values using a sliding window, applying a condition and evaluate it to each sub-window then return the first or last index of the windows that match condition

Description

This function iterates through values using a sliding window, applying a condition and evaluate it to each sub-window then return the first or last index of the windows that match condition

Usage

consec_idx(index, value, expr, .after = 7, .f = "min", .messages = F)

Arguments

index

date. i-ndex date.

value

numeric. Count values.

expr

expression. type of .x > 2.

.after

The number of values after the current element of .i to include in the sliding window. Set to Inf to select all elements after the current element. Negative values are allowed, which allows you to "look backwards".

.f

function to apply to find min o max of all windows.

messages

show messages for more information about the windows.

Value

window's vector.


diegogarcilazo/myutilities documentation built on Jan. 4, 2024, 2:11 p.m.