Turn a vector of quantile distributions into a list-col
Source:R/pivot_quantiles.R
nested_quantiles.Rd
Turn a vector of quantile distributions into a list-col
Examples
library(dplyr)
library(tidyr)
edf <- case_death_rate_subset[1:3, ]
edf$q <- dist_quantiles(list(1:5, 2:4, 3:10), list(1:5 / 6, 2:4 / 5, 3:10 / 11))
edf_nested <- edf %>% mutate(q = nested_quantiles(q))
edf_nested %>% unnest(q)
#> An `epi_df` object, 16 x 6 with metadata:
#> * geo_type = state
#> * time_type = day
#> * as_of = 2022-05-31 19:08:25.791826
#>
#> # A tibble: 16 × 6
#> geo_value time_value case_rate death_rate values quantile_levels
#> * <chr> <date> <dbl> <dbl> <dbl> <dbl>
#> 1 ak 2020-12-31 35.9 0.158 1 0.167
#> 2 ak 2020-12-31 35.9 0.158 2 0.333
#> 3 ak 2020-12-31 35.9 0.158 3 0.5
#> 4 ak 2020-12-31 35.9 0.158 4 0.667
#> 5 ak 2020-12-31 35.9 0.158 5 0.833
#> 6 al 2020-12-31 65.1 0.438 2 0.4
#> 7 al 2020-12-31 65.1 0.438 3 0.6
#> 8 al 2020-12-31 65.1 0.438 4 0.8
#> 9 ar 2020-12-31 66.0 1.27 3 0.273
#> 10 ar 2020-12-31 66.0 1.27 4 0.364
#> 11 ar 2020-12-31 66.0 1.27 5 0.455
#> 12 ar 2020-12-31 66.0 1.27 6 0.545
#> 13 ar 2020-12-31 66.0 1.27 7 0.636
#> 14 ar 2020-12-31 66.0 1.27 8 0.727
#> 15 ar 2020-12-31 66.0 1.27 9 0.818
#> 16 ar 2020-12-31 66.0 1.27 10 0.909