streak_run | R Documentation |
Calculates running series of consecutive elements
streak_run(
x,
k = integer(0),
lag = integer(1),
idx = integer(0),
at = integer(0),
na_rm = TRUE,
na_pad = FALSE
)
x |
any type vector which running function is calculated on |
k |
( |
lag |
( |
idx |
( |
at |
( |
na_rm |
|
na_pad |
( |
streak numeric vector of length equals length of x
containing
number of consecutive occurrences.
set.seed(11)
x1 <- sample(c("a", "b"), 15, replace = TRUE)
x2 <- sample(c(NA_character_, "a", "b"), 15, replace = TRUE)
k <- sample(1:4, 15, replace = TRUE)
streak_run(x1) # simple streak run
streak_run(x1, k = 2) # streak run within 2-element window
streak_run(x2, na_pad = TRUE, k = 3) # streak run within k=3 with padding NA
streak_run(x1, k = k) # streak run within varying window size specified by vector k
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.