roll_count: Count the number of consecutive 'TRUE' elements in a Boolean...

View source: R/RcppExports.R

roll_countR Documentation

Count the number of consecutive TRUE elements in a Boolean vector, and reset the count to zero after every FALSE element.

Description

Count the number of consecutive TRUE elements in a Boolean vector, and reset the count to zero after every FALSE element.

Usage

roll_count(timeser)

Arguments

timeser

A Boolean vector of data.

Details

The function roll_count() calculates the number of consecutive TRUE elements in a Boolean vector, and it resets the count to zero after every FALSE element.

For example, the Boolean vector FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, is translated into 0, 1, 2, 0, 0, 1, 2, 3, 4, 5, 0.

Value

An integer vector of the same length as the argument timeser.

Examples

## Not run: 
# Calculate the number of consecutive TRUE elements
drop(HighFreq::roll_count(c(FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE)))

## End(Not run)  # end dontrun


algoquant/HighFreq documentation built on June 10, 2025, 3:54 p.m.