event_distance: Event Distance

Description Usage Arguments Details Note

View source: R/event_distance.R

Description

Distance from each event to nearest non-event

Usage

1
2
event_distance(x, positions = seq_along(x), event_value = 1,
  keep_sign = FALSE)

Arguments

x

vector of values indicating events (and arbitrary values indicating non-events)

positions

indicating locations separating distance between values in x; see example use in event_stretches and its use of year; default assumes event spacing

event_value

value in x inidicating an event

keep_sign

Logical; should distances retain their sign? See Note

Details

Finds whether each value in a streak (run) is closer to the beginning or the end of the streak, and then finds the distance to whichever is nearest.

Note

When keep_sign is TRUE, the sign of values equidistant from 2 non-events may be misleading: even though the event is not closer to either, the sign will be negative.


rBatt/trawlDiversity documentation built on Aug. 14, 2021, 1:01 p.m.