max_duration: Determine the length of the (first) longest run

View source: R/sequence_characteristics.R

max_durationR Documentation

Determine the length of the (first) longest run

Description

Determine the length of the (first) longest run

Usage

max_duration(x, target_val = 1L, return_doys = FALSE)

Arguments

x

A vector.

target_val

A value. Runs of target_val in x are used.

return_doys

A logical value.

Value

A numeric vector with one or three elements including the length of the longest run of value target_val (the first if multiple runs are of equally the longest) and, if return_doys == TRUE, then the start and end position of that longest run.

Examples

max_duration(0, target_val = 1)
x <- c(rep(3, 3), rep(10, 10), 4, rep(10, 20), rep(3, 6))
max_duration(x, 10, FALSE)
max_duration(x, 10, TRUE)


DrylandEcology/rSW2utils documentation built on Dec. 9, 2023, 10:44 p.m.