pivot_quantiles_longer: Pivot columns containing 'dist_quantile' longer

View source: R/pivot_quantiles.R

pivot_quantiles_longerR Documentation

Pivot columns containing dist_quantile longer

Description

Selected columns that contain dist_quantiles will be "lengthened" with the quantile levels serving as 1 column and the values as another. If multiple columns are selected, these will be prefixed with the column name.

Usage

pivot_quantiles_longer(.data, ..., .ignore_length_check = FALSE)

Arguments

.data

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

...

<tidy-select> One or more unquoted expressions separated by commas. Variable names can be used as if they were positions in the data frame, so expressions like x:y can be used to select a range of variables.

.ignore_length_check

If multiple columns are selected, as long as each row has contains the same number of quantiles, the result will be reasonable. But if, for example, var1[1] has 5 quantiles while var2[1] has 7, then the only option would be to recycle everything, creating a very long result. By default, this would throw an error. But if this is really the goal, then the error can be bypassed by setting this argument to TRUE. The quantiles in the first selected column will vary the fastest.

Value

An object of the same class as .data.

Examples

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

pivot_quantiles_longer(tib, "d1")
pivot_quantiles_longer(tib, dplyr::ends_with("1"))
pivot_quantiles_longer(tib, d1, d2)

cmu-delphi/epipredict documentation built on March 5, 2025, 12:17 p.m.