Skip to contents

Any selected columns that contain quantile_pred will be "widened" with the "taus" (quantile) serving as names and the values in the data frame. When pivoting multiple columns, the original column name will be used as a prefix.

Usage

pivot_quantiles_wider(.data, ...)

Arguments

.data

A data frame, or a data frame extension such as a tibble or epi_df.

...

<tidy-select> One unquoted expressions separated by commas. Variable names can be used as if they were positions in the data frame. Note that only one variable can be selected for this operation.

Value

An object of the same class as .data

Examples

d1 <- quantile_pred(rbind(1:3, 2:4), 1:3 / 4)
d2 <- quantile_pred(rbind(2:4, 3:5), 2:4 / 5)
tib <- tibble(g = c("a", "b"), d1 = d1, d2 = d2)

pivot_quantiles_wider(tib, "d1")
#> # A tibble: 2 × 5
#>   g            d2 `0.25` `0.5` `0.75`
#>   <chr> <qtls(3)>  <int> <int>  <int>
#> 1 a         [2.5]      1     2      3
#> 2 b         [3.5]      2     3      4
pivot_quantiles_wider(tib, dplyr::ends_with("2"))
#> # A tibble: 2 × 5
#>   g            d1 `0.4` `0.6` `0.8`
#>   <chr> <qtls(3)> <int> <int> <int>
#> 1 a           [2]     2     3     4
#> 2 b           [3]     3     4     5
pivot_quantiles_wider(tib, d2)
#> # A tibble: 2 × 5
#>   g            d1 `0.4` `0.6` `0.8`
#>   <chr> <qtls(3)> <int> <int> <int>
#> 1 a           [2]     2     3     4
#> 2 b           [3]     3     4     5