| roll_count | R Documentation |
TRUE elements in a Boolean vector,
and reset the count to zero after every FALSE element.Count the number of consecutive TRUE elements in a Boolean vector,
and reset the count to zero after every FALSE element.
roll_count(timeser)
timeser |
A Boolean vector of data. |
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.
An integer vector of the same length as the argument
timeser.
## 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.