R/add_point_forecasts.R

Defines functions add_point_forecasts

Documented in add_point_forecasts

#' Add point forecasts to a quantile forecasts data.frame
#'
#' @param data The `data.frame` containing quantile forecasts
#'
#' @return
#' The `data.frame` from `data` with additional rows containing the point
#' forecasts
#'
#' @importFrom dplyr %>% filter mutate
#'
#' @autoglobal
#'
#' @export
add_point_forecasts <- function(data) {

  data %>%
    filter(quantile == 0.5) %>%
    mutate(type = "point",
           quantile = NA_real_) %>%
    rbind(data)

}
epiforecasts/forecasthubutils2 documentation built on July 1, 2023, 11:50 a.m.