ts_event_dist: Distance to dummy-coded events.

Description Usage Arguments Value Examples

View source: R/ts_event_dist.R

Description

Given a dummy coded (0 for non-event and 1 for event) timeseries, determine the number of periods (vector elements) until the next, and since the last event.

Usage

1
2
3
4
5

Arguments

x

A numeric vector of 0s and 1s.

Value

ts_next_in and ts_last_before return a numeric vector of length(x).

ts_event_dist returns a data.frame with columns last_before and next_in, and length(x) rows.

Examples

1
2
3
ts_next_in(c(0, 0, 0, 1, 0, 1, 0))
ts_last_before(c(0, 0, 0, 1, 0, 1, 0))
ts_event_dist(c(0, 0, 0, 1, 0, 1, 0))

thorepet/thoremisc documentation built on Oct. 8, 2021, 7:48 a.m.