rle_df - create a run-length-encoding data.frame
rle_df.Rd
Given an rle
this function will return a data.frame of starts, ends, and indexes thereof of the run lengths.
Credit: https://stackoverflow.com/questions/43875716/find-start-and-end-positions-indices-of-runs-consecutive-values
See also
Other vectors:
len_unique()
,
names_values_switch()
,
rle_groups()
,
rle_seq()
,
sort_by_names()
,
true_names()
,
unify_vec_preserve_order()
,
unique_with_names()
,
vlookup()
,
vlookup_from_ref()
,
zchar_remove()
Examples
rle_df(sample(c(TRUE,FALSE), replace = TRUE, 100))
#> # A tibble: 60 × 4
#> lengths values start end
#> <int> <lgl> <dbl> <int>
#> 1 1 TRUE 1 1
#> 2 1 FALSE 2 2
#> 3 3 TRUE 3 5
#> 4 1 FALSE 6 6
#> 5 1 TRUE 7 7
#> 6 2 FALSE 8 9
#> 7 2 TRUE 10 11
#> 8 3 FALSE 12 14
#> 9 2 TRUE 15 16
#> 10 1 FALSE 17 17
#> # ℹ 50 more rows