Description Usage Arguments Examples
View source: R/consecutive_T.R
Counts the number of consecutive TRUE
s in a logical vector. Restarts
count of consecutive TRUE
s when FALSE
is encountered. Vector
can either be a logical
or a condition that evaluates to a
logical
. See examples. Based on a note from Bill Dunlap to R-devel
(http://tolstoy.newcastle.edu.au/R/e4/devel/08/04/1206.html)
1 |
x |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 | tf <- sample(c(TRUE, FALSE), 15, TRUE, prob = c(0.75, 0.25))
consecutive_T(tf)
x <- rnorm(15, mean = -0.5)
consecutive_T(x < 0)
## Not run:
# Works in tidyverse pipe context
library(dplyr)
df <- tibble(x = rnorm(10, -0.25)) %>%
mutate(cons_lt_zero = consecutive_T(x < 0))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.