Skip to contents

Given a forecast data frame, compute quantiles from raw data or existing quantile columns, depending on what is present.

Usage

get_quantile(df, perc)

Arguments

df

A forecast data frame. It should contain raw or quantile data.

perc

A percentage, from 0 to 100.

Value

A data frame with a time column and a quant column, containing the requested quantile data

Examples

df1 <- data.frame(time=rep(1:3,each=3), sim=rep(1:3, 3), val=c(4:6, 7:9, 10:12))
df2 <- data.frame(time=1:3, val_q50=c(1000, 2000, 3000))

casteval:::get_quantile(df1, 50)
#> # A tibble: 3 × 2
#>    time quant
#>   <int> <dbl>
#> 1     1     5
#> 2     2     8
#> 3     3    11
casteval:::get_quantile(df2, 50)
#>   time quant
#> 1    1  1000
#> 2    2  2000
#> 3    3  3000