Skip to contents

Identify the length of runs (of values TRUE) and their frequencies.

Usage

get_runs(x)

Arguments

x

Boolean vector

Value

a table of the number of runs of TRUEs

Examples

x <- rbinom(100, size = 1, prob = 1 / 3)
get_runs(x == 1) # expected value for longest run is 3
#> 
#>  1  2  3  4  5 
#> 17  4  1  1  1 
get_runs(x == 0) # expected value for longest run is 6
#> 
#> 1 2 3 4 5 6 7 
#> 8 7 3 1 3 1 1