NA
>na_rle_cut.Rd
Cut and aggregate run length encoding <NA
>
na_rle_cut(x, by)
x | An object returned by |
---|---|
by | A function applied to |
A tibble contains:
indices
: aggregated indices.
n_run
: the number of unique runs for each by
.
n_na
: the total number of NA
s for each by
.
Other rectangling functions: na_rle_expand
if (!requireNamespace("nycflights13", quietly = TRUE)) { stop("Please install the nycflights13 package to run these following examples.") } if (!requireNamespace("tidyr", quietly = TRUE)) { stop("Please install the tidyr package to run these following examples.") } library(dplyr, warn.conflicts = FALSE) nycflights13::weather %>% group_by(origin) %>% summarise(wind_gust_na = list_of_na_rle(wind_gust, time_hour)) %>% mutate(wind_gust_na = na_rle_cut(wind_gust_na, by = tsibble::yearmonth)) %>% tidyr::unnest(cols = wind_gust_na)#> # A tibble: 36 x 4 #> origin indices n_run n_na #> <chr> <date> <int> <int> #> 1 EWR 2013-01-01 55 583 #> 2 EWR 2013-02-01 50 482 #> 3 EWR 2013-03-01 84 480 #> 4 EWR 2013-04-01 59 514 #> 5 EWR 2013-05-01 52 600 #> 6 EWR 2013-06-01 56 548 #> 7 EWR 2013-07-01 62 632 #> 8 EWR 2013-08-01 39 657 #> 9 EWR 2013-09-01 45 616 #> 10 EWR 2013-10-01 51 629 #> # … with 26 more rows