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

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 
#> 17  6  4 
get_runs(x == 0) # expected value for longest run is 6
#> 
#>  1  2  3  4  5  7 
#> 12  9  2  1  1  2