mark_longest_run: Find and mark the longest run of TRUEs in a boolean vector

View source: R/number_tools.R

mark_longest_runR Documentation

Find and mark the longest run of TRUEs in a boolean vector

Description

Find and mark the longest run of TRUEs in a boolean vector

Usage

mark_longest_run(vec)

Arguments

vec

(Logical) A vector.

Value

A new logical vector of the same length as vec, where the longest run of TRUEs is marked with TRUE and all other values are marked FALSE. If there are two runs of TRUE with equal length in vec, both will be reported in the results.

Authors

Source

https://stackoverflow.com/a/37447844

Examples

input <- c(TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE)
mark_longest_run(input)

#> [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE


DesiQuintans/desiderata documentation built on April 9, 2023, 5:43 a.m.