streak_length: Streak Length

Description Usage Arguments Details Value Examples

View source: R/streak_length.R

Description

Finds streaks in a vector containing consecutively-repeated values, and in each streak indicates the number of values into the streak so far

Usage

1
streak_length(x, streak_val = 1, fill_val = 0)

Arguments

x

vector of numbers

streak_val

value in x considered as part of streak

fill_val

value in output to indicate indices that are part of non-streak

Details

Functions like rle, but within each run (streak) indicates the current position of each value where the first value in the streak is 1 and the last value in the streak is the length of the streak

Value

Returns a vector the same length as x that contains streak lengths and 0's

Examples

1
streak_length(c(1,1,1,0,0,1,0,1,0,0,1,1))

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