From d8b16b83e2214f320f99c289c8e5a7e327abdc3f Mon Sep 17 00:00:00 2001 From: "Dylan H. Morris" Date: Wed, 20 Nov 2024 19:51:03 -0500 Subject: [PATCH 1/8] Add utility function for pivoting hubverse quantile tables wider --- R/pivot_hubverse_quantiles_wider.R | 70 ++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 R/pivot_hubverse_quantiles_wider.R diff --git a/R/pivot_hubverse_quantiles_wider.R b/R/pivot_hubverse_quantiles_wider.R new file mode 100644 index 0000000..683049c --- /dev/null +++ b/R/pivot_hubverse_quantiles_wider.R @@ -0,0 +1,70 @@ +#' Pivot a hubverse quantile table wider with columns representing +#' individual quantile levels. +#' +#' @param hubverse_table hubverse-format forecast table to pivot, +#' as a [`tibble`][tibble::tibble()] +#' @param pivot_quantiles quantiles to pivot to columns, as a vector or +#' named vector. Default `c("point" = 0.5, "lower" = 0.025, "upper" = 0.975)`, +#' i.e. get the median and the central 95% interquantile interval, +#' with names "point" for the median, "lower" for the 0.025th quantile, +#' and "upper" for the 0.975th quantile. +#' @return A pivoted version of the hubverse table in which each +#' forecast for a given target, horizon, reference_date, and +#' location corresponds to a single row with multiple +#' value columns, one for each of the quantiles in `pivot_quantiles`, +#' and named according to the corresponding names given in that vector, +#' or generically as `q_` if an unnamed numeric +#' vector is provided. +#' So with the default `pivot_quantiles`, the output will have three +#' value columns named `lower"`, `"point"`, and `"upper"` +#' @export +pivot_hubverse_quantiles_wider <- function(hubverse_table, + pivot_quantiles = c( + "point" = 0.5, + "lower" = 0.025, + "upper" = 0.975 + )) { + if (!("quantile" %in% hubverse_table$output_type)) { + cli::cli_abort(message = paste0( + "Hubverse table must contain at least ", + "one quantile forecast." + )) + } + + dat <- hubverse_table |> + dplyr::filter(.data$output_type == "quantile") |> + dplyr::mutate("output_type_id" = as.numeric(.data$output_type_id)) + + pivot_quantiles_present <- pivot_quantiles %in% hubverse_table$output_type_id + + if (!all(pivot_quantiles_present)) { + missing_pivot_quantiles <- pivot_quantiles[!pivot_quantiles_present] + cli::cli_abort(message = paste0( + "Hubverse table is missing one or more of ", + "the requested pivot quantiles for all forecasts. ", + "The following requested pivot quantiles ", + "could not be found: {missing_pivot_quantiles}." + )) + } + + if (is.null(names(pivot_quantiles))) { + names(pivot_quantiles) <- paste("q", pivot_quantiles, sep = "") + } + + pivot_quant_map <- setNames(names(pivot_quantiles), pivot_quantiles) + + dat <- dat |> + dplyr::filter(.data$output_type_id %in% !!pivot_quantiles) |> + dplyr::mutate( + "which_quantile" = dplyr::recode( + .data$output_type_id, + !!!pivot_quant_map + ) + ) |> + dplyr::select(-"output_type", -"output_type_id") |> + tidyr::pivot_wider( + names_from = "which_quantile", + values_from = "value" + ) + return(dat) +} From 0b4708484634cd9d1c133c0402374938d4255c6b Mon Sep 17 00:00:00 2001 From: "Dylan H. Morris" Date: Wed, 20 Nov 2024 19:52:22 -0500 Subject: [PATCH 2/8] Add docs for pivot func --- NAMESPACE | 2 ++ man/pivot_hubverse_quantiles_wider.Rd | 37 +++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 man/pivot_hubverse_quantiles_wider.Rd diff --git a/NAMESPACE b/NAMESPACE index 04261b2..04b762b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -16,7 +16,9 @@ export(get_hubverse_table) export(inferencedata_to_tidy_draws) export(location_lookup) export(nhsn_soda_query) +export(pivot_hubverse_quantiles_wider) export(plot_forecast_quantiles) +export(plot_hubverse_pointintervals) export(plot_hubverse_quantiles) export(plot_hubverse_quantiles_loc) export(plots_to_pdf) diff --git a/man/pivot_hubverse_quantiles_wider.Rd b/man/pivot_hubverse_quantiles_wider.Rd new file mode 100644 index 0000000..a62a3b3 --- /dev/null +++ b/man/pivot_hubverse_quantiles_wider.Rd @@ -0,0 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/pivot_hubverse_quantiles_wider.R +\name{pivot_hubverse_quantiles_wider} +\alias{pivot_hubverse_quantiles_wider} +\title{Pivot a hubverse quantile table wider with columns representing +individual quantile levels.} +\usage{ +pivot_hubverse_quantiles_wider( + hubverse_table, + pivot_quantiles = c(point = 0.5, lower = 0.025, upper = 0.975) +) +} +\arguments{ +\item{hubverse_table}{hubverse-format forecast table to pivot, +as a \code{\link[tibble:tibble]{tibble}}} + +\item{pivot_quantiles}{quantiles to pivot to columns, as a vector or +named vector. Default \code{c("point" = 0.5, "lower" = 0.025, "upper" = 0.975)}, +i.e. get the median and the central 95\% interquantile interval, +with names "point" for the median, "lower" for the 0.025th quantile, +and "upper" for the 0.975th quantile.} +} +\value{ +A pivoted version of the hubverse table in which each +forecast for a given target, horizon, reference_date, and +location corresponds to a single row with multiple +value columns, one for each of the quantiles in \code{pivot_quantiles}, +and named according to the corresponding names given in that vector, +or generically as \verb{q_} if an unnamed numeric +vector is provided. +So with the default \code{pivot_quantiles}, the output will have three +value columns named \verb{lower"}, \code{"point"}, and \code{"upper"} +} +\description{ +Pivot a hubverse quantile table wider with columns representing +individual quantile levels. +} From ee7a868f67110fb384366f15f6459c525111715c Mon Sep 17 00:00:00 2001 From: "Dylan H. Morris" Date: Wed, 20 Nov 2024 20:56:43 -0500 Subject: [PATCH 3/8] Generalize recode_locations, add pointinterval plotter --- DESCRIPTION | 1 + NAMESPACE | 1 + R/plot_hubverse_pointinterval.R | 87 +++++++++++++++++++++++++++++ R/plot_quantiles.R | 4 +- R/recode_locations.R | 25 +++++++-- R/theme_forecasttools.R | 12 ++++ man/location_lookup.Rd | 16 +++++- man/plot_hubverse_pointintervals.Rd | 55 ++++++++++++++++++ man/theme_forecasttools.Rd | 20 +++++++ 9 files changed, 212 insertions(+), 9 deletions(-) create mode 100644 R/plot_hubverse_pointinterval.R create mode 100644 R/theme_forecasttools.R create mode 100644 man/plot_hubverse_pointintervals.Rd create mode 100644 man/theme_forecasttools.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 31346de..eb5f2fe 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -25,6 +25,7 @@ Imports: dplyr, fs, gert, + ggdist, ggplot2, glue, gridExtra, diff --git a/NAMESPACE b/NAMESPACE index 04b762b..a8536cc 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -27,6 +27,7 @@ export(rank_sampled_trajectories) export(sample_aggregated_trajectories) export(soql_is_in) export(target_end_dates_from_horizons) +export(theme_forecasttools) export(to_location_table_column) export(trajectories_to_quantiles) export(update_hub) diff --git a/R/plot_hubverse_pointinterval.R b/R/plot_hubverse_pointinterval.R new file mode 100644 index 0000000..1fedb0d --- /dev/null +++ b/R/plot_hubverse_pointinterval.R @@ -0,0 +1,87 @@ +#' Plot a set of hubverse-formatted forecast +#' as a set of pointintervals. +#' +#' @param hubverse_table Hubverse table, as a [`tibble`][tibble::tibble()] +#' @param horizon horizons to plot, as a vector of integers. If `NULL`, +#' plot all available, each in its own facet. Default `NULL`. +#' @param locations set of locations to plot. If NULL, +#' all locations are plotted. Otherwise, a vector +#' of location values to plot, as USPS-style +#' abbreviations (e.g. `c("US", "AL", "AK"`), +#' US hubverse submission location codes ( +#' e.g. `c("US", 01, 02)`), or full English +#' jurisdiction names +#' (e.g. `c("United States, "Alabama", "Alaska")`. +#' Default `NULL`. +#' @param location_column_format format of the hubverse table +#' `location` column. +#' Permitted formats are `"abbr"` (state/territory +#' or nation two letter USPS abbreviation), `"hub"` ( +#' legacy 2-digit FIPS code for states and territories, `US` +#' for the USA as a whole), and `"long_name"` (full English +#' jurisdiction names; not recommended). Default `"hub"`. +#' @param location_output_format how to code locations in the output plot. +#' Permitted formats are `"abbr"` (state/territory +#' or nation two letter USPS abbreviation), `"hub"` ( +#' legacy 2-digit FIPS code for states and territories, `US` +#' #' for the USA as a whole), and `"long_name"` (full English +#' jurisdiction names). Default `"abbr"`. +#' @return A ggplot2 plot of the forecasts as pointintervals +#' @export +plot_hubverse_pointintervals <- function(hubverse_table, + horizons = NULL, + point_estimate_quantile = 0.5, + lower_limit_quantile = 0.025, + upper_limit_quantile = 0.975, + location_input_format = "hub", + location_output_format = "abbr") { + if (is.null(horizons)) { + horizons <- unique(hubverse_table$horizon) + } + + pivoted <- hubverse_table |> + pivot_hubverse_quantiles_wider( + pivot_quantiles = c( + "point" = point_estimate_quantile, + "lower" = lower_limit_quantile, + "upper" = upper_limit_quantile + ) + ) |> + dplyr::mutate( + "location" = location_lookup( + .data$location, + location_input_format, + location_output_format + ) + ) |> + dplyr::filter(.data$horizon %in% horizons) + + ## order by the median at the first horizon plotted + loc_levels <- pivoted |> + dplyr::filter( + .data$horizon == min(.data$horizon) + ) |> + dplyr::arrange(.data$point) |> + dplyr::pull("location") + + pivoted <- pivoted |> + dplyr::mutate("location" = factor( + location, + levels = loc_levels, + ordered = TRUE + )) + + plot <- pivoted |> + ggplot2::ggplot(ggplot2::aes_string( + y = "location", + x = "point", + xmin = "lower", + xmax = "upper" + )) + + ggdist::geom_pointinterval() + + ggplot2::facet_wrap(~horizon ~ target) + + ggplot2::labs(x = "target value") + + theme_forecasttools() + + return(plot) +} diff --git a/R/plot_quantiles.R b/R/plot_quantiles.R index cc282d7..e8a9289 100644 --- a/R/plot_quantiles.R +++ b/R/plot_quantiles.R @@ -169,12 +169,12 @@ plot_hubverse_quantiles_loc <- function(location, ggplot2::scale_y_continuous( trans = ytrans ) + - ggplot2::theme_minimal(base_size = 15) + ggplot2::labs( y = target_name, x = "Date" ) + - ggplot2::ggtitle(plot_title) + ggplot2::ggtitle(plot_title) + + theme_forecasttools() ) diff --git a/R/recode_locations.R b/R/recode_locations.R index 85433d8..9a0edd4 100644 --- a/R/recode_locations.R +++ b/R/recode_locations.R @@ -83,7 +83,6 @@ to_location_table_column <- function(location_format) { #' corresponding to a given location vector #' and format, with repeats possible #' @param location_vector vector of location values -#' @param location_format how the vector is coded. #' @param location_format format in which the location #' vector is coded. #' Permitted formats are `"abbr"` (state/territory @@ -91,21 +90,37 @@ to_location_table_column <- function(location_format) { #' (legacy 2-digit FIPS code for states and territories, `US` #' for the USA as a whole), and `"long_name"` (full English #' name for jurisdiction). -#' @return the rows of the [us_location_table] +#' @param location_output_format Return only this column of the +#' output table, if it is provided. Otherwise return the whole +#' table. Default `NULL` (return all columns). +# Permitted formats are `"abbr"` (state/territory +#' or nation two letter USPS abbreviation), `"hub"` +#' (legacy 2-digit FIPS code for states and territories, `US` +#' for the USA as a whole), and `"long_name"` (full English +#' name for jurisdiction). +#' @return the corresponding rows of the [us_location_table] #' matching the location vector, with repeats possible. #' @export location_lookup <- function(location_vector, - location_format) { + location_input_format, + location_output_format = NULL) { ## coerce location vector to character ## (handles case of just states with no US, ## by FIPS, which R will default to treating ## as numeric) location_vector <- as.character(location_vector) - join_key <- to_location_table_column(location_format) + join_key <- to_location_table_column(location_input_format) locs <- tibble::tibble({{ join_key }} := !!location_vector) |> dplyr::inner_join(forecasttools::us_location_table, by = join_key ) - return(locs) + if (is.null(location_output_format)) { + result <- locs + } else { + output_column <- to_location_table_column(location_output_format) + result <- locs[[output_column]] + } + + return(result) } diff --git a/R/theme_forecasttools.R b/R/theme_forecasttools.R new file mode 100644 index 0000000..c4ea2c2 --- /dev/null +++ b/R/theme_forecasttools.R @@ -0,0 +1,12 @@ +#' forecasttools ggplot2 theme, built +#' on top of [ggplot2::theme_minimal()] +#' @param ... arguments passed to [ggplot2::theme()] +#' @return The theme, which can be added to a ggplot +#' object. +#' @export +theme_forecasttools <- function(...) { + return( + ggplot2::theme_minimal(base_size = 15) + + ggplot2::theme(...) + ) +} diff --git a/man/location_lookup.Rd b/man/location_lookup.Rd index dee0369..d74fa5a 100644 --- a/man/location_lookup.Rd +++ b/man/location_lookup.Rd @@ -6,11 +6,23 @@ corresponding to the entries of a given vector.} \usage{ -location_lookup(location_vector, location_format) +location_lookup( + location_vector, + location_input_format, + location_output_format = NULL +) } \arguments{ \item{location_vector}{vector of location values} +\item{location_output_format}{Return only this column of the +output table, if it is provided. Otherwise return the whole +table. Default \code{NULL} (return all columns). +or nation two letter USPS abbreviation), \code{"hub"} +(legacy 2-digit FIPS code for states and territories, \code{US} +for the USA as a whole), and \code{"long_name"} (full English +name for jurisdiction).} + \item{location_format}{format in which the location vector is coded. Permitted formats are \code{"abbr"} (state/territory @@ -20,7 +32,7 @@ for the USA as a whole), and \code{"long_name"} (full English name for jurisdiction).} } \value{ -the rows of the \link{us_location_table} +the corresponding rows of the \link{us_location_table} matching the location vector, with repeats possible. } \description{ diff --git a/man/plot_hubverse_pointintervals.Rd b/man/plot_hubverse_pointintervals.Rd new file mode 100644 index 0000000..ec2e8c5 --- /dev/null +++ b/man/plot_hubverse_pointintervals.Rd @@ -0,0 +1,55 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot_hubverse_pointinterval.R +\name{plot_hubverse_pointintervals} +\alias{plot_hubverse_pointintervals} +\title{Plot a set of hubverse-formatted forecast +as a set of pointintervals.} +\usage{ +plot_hubverse_pointintervals( + hubverse_table, + horizons = NULL, + point_estimate_quantile = 0.5, + lower_limit_quantile = 0.025, + upper_limit_quantile = 0.975, + location_input_format = "hub", + location_output_format = "abbr" +) +} +\arguments{ +\item{hubverse_table}{Hubverse table, as a \code{\link[tibble:tibble]{tibble}}} + +\item{location_output_format}{how to code locations in the output plot. +Permitted formats are \code{"abbr"} (state/territory +or nation two letter USPS abbreviation), \code{"hub"} ( +legacy 2-digit FIPS code for states and territories, \code{US} +#' for the USA as a whole), and \code{"long_name"} (full English +jurisdiction names). Default \code{"abbr"}.} + +\item{horizon}{horizons to plot, as a vector of integers. If \code{NULL}, +plot all available, each in its own facet. Default \code{NULL}.} + +\item{locations}{set of locations to plot. If NULL, +all locations are plotted. Otherwise, a vector +of location values to plot, as USPS-style +abbreviations (e.g. \verb{c("US", "AL", "AK"}), +US hubverse submission location codes ( +e.g. \code{c("US", 01, 02)}), or full English +jurisdiction names +(e.g. \verb{c("United States, "Alabama", "Alaska")}. +Default \code{NULL}.} + +\item{location_column_format}{format of the hubverse table +\code{location} column. +Permitted formats are \code{"abbr"} (state/territory +or nation two letter USPS abbreviation), \code{"hub"} ( +legacy 2-digit FIPS code for states and territories, \code{US} +for the USA as a whole), and \code{"long_name"} (full English +jurisdiction names; not recommended). Default \code{"hub"}.} +} +\value{ +A ggplot2 plot of the forecasts as pointintervals +} +\description{ +Plot a set of hubverse-formatted forecast +as a set of pointintervals. +} diff --git a/man/theme_forecasttools.Rd b/man/theme_forecasttools.Rd new file mode 100644 index 0000000..e53a9e3 --- /dev/null +++ b/man/theme_forecasttools.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/theme_forecasttools.R +\name{theme_forecasttools} +\alias{theme_forecasttools} +\title{forecasttools ggplot2 theme, built +on top of \code{\link[ggplot2:ggtheme]{ggplot2::theme_minimal()}}} +\usage{ +theme_forecasttools(...) +} +\arguments{ +\item{...}{arguments passed to \code{\link[ggplot2:theme]{ggplot2::theme()}}} +} +\value{ +The theme, which can be added to a ggplot +object. +} +\description{ +forecasttools ggplot2 theme, built +on top of \code{\link[ggplot2:ggtheme]{ggplot2::theme_minimal()}} +} From 0ff50934b030c3efe011bd4be6b2f6c382094759 Mon Sep 17 00:00:00 2001 From: "Dylan H. Morris" Date: Wed, 20 Nov 2024 21:04:06 -0500 Subject: [PATCH 4/8] Fix docs typo for plot function --- R/plot_hubverse_pointinterval.R | 4 ++-- man/plot_hubverse_pointintervals.Rd | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/R/plot_hubverse_pointinterval.R b/R/plot_hubverse_pointinterval.R index 1fedb0d..3ef6297 100644 --- a/R/plot_hubverse_pointinterval.R +++ b/R/plot_hubverse_pointinterval.R @@ -1,5 +1,5 @@ -#' Plot a set of hubverse-formatted forecast -#' as a set of pointintervals. +#' Plot a table of hubverse-formatted forecasts +#' as pointintervals #' #' @param hubverse_table Hubverse table, as a [`tibble`][tibble::tibble()] #' @param horizon horizons to plot, as a vector of integers. If `NULL`, diff --git a/man/plot_hubverse_pointintervals.Rd b/man/plot_hubverse_pointintervals.Rd index ec2e8c5..91d5f5e 100644 --- a/man/plot_hubverse_pointintervals.Rd +++ b/man/plot_hubverse_pointintervals.Rd @@ -2,8 +2,8 @@ % Please edit documentation in R/plot_hubverse_pointinterval.R \name{plot_hubverse_pointintervals} \alias{plot_hubverse_pointintervals} -\title{Plot a set of hubverse-formatted forecast -as a set of pointintervals.} +\title{Plot a table of hubverse-formatted forecasts +as pointintervals} \usage{ plot_hubverse_pointintervals( hubverse_table, @@ -50,6 +50,6 @@ jurisdiction names; not recommended). Default \code{"hub"}.} A ggplot2 plot of the forecasts as pointintervals } \description{ -Plot a set of hubverse-formatted forecast -as a set of pointintervals. +Plot a table of hubverse-formatted forecasts +as pointintervals } From cd5464ae11707b706337d555144e13542889e69c Mon Sep 17 00:00:00 2001 From: "Dylan H. Morris" Date: Wed, 20 Nov 2024 21:05:10 -0500 Subject: [PATCH 5/8] more docs tweaks --- R/theme_forecasttools.R | 5 +++-- man/theme_forecasttools.Rd | 6 ++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/R/theme_forecasttools.R b/R/theme_forecasttools.R index c4ea2c2..bb9977c 100644 --- a/R/theme_forecasttools.R +++ b/R/theme_forecasttools.R @@ -1,5 +1,6 @@ -#' forecasttools ggplot2 theme, built -#' on top of [ggplot2::theme_minimal()] +#' forecasttools ggplot2 theme. +#' +#' Built on top of [ggplot2::theme_minimal()] #' @param ... arguments passed to [ggplot2::theme()] #' @return The theme, which can be added to a ggplot #' object. diff --git a/man/theme_forecasttools.Rd b/man/theme_forecasttools.Rd index e53a9e3..85df2f9 100644 --- a/man/theme_forecasttools.Rd +++ b/man/theme_forecasttools.Rd @@ -2,8 +2,7 @@ % Please edit documentation in R/theme_forecasttools.R \name{theme_forecasttools} \alias{theme_forecasttools} -\title{forecasttools ggplot2 theme, built -on top of \code{\link[ggplot2:ggtheme]{ggplot2::theme_minimal()}}} +\title{forecasttools ggplot2 theme.} \usage{ theme_forecasttools(...) } @@ -15,6 +14,5 @@ The theme, which can be added to a ggplot object. } \description{ -forecasttools ggplot2 theme, built -on top of \code{\link[ggplot2:ggtheme]{ggplot2::theme_minimal()}} +Built on top of \code{\link[ggplot2:ggtheme]{ggplot2::theme_minimal()}} } From a6c5ef53d7a6459b60b68ce5ba85d5218f842574 Mon Sep 17 00:00:00 2001 From: "Dylan H. Morris" Date: Wed, 20 Nov 2024 21:19:50 -0500 Subject: [PATCH 6/8] Fix location_lookup docs --- R/recode_locations.R | 2 +- man/location_lookup.Rd | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/R/recode_locations.R b/R/recode_locations.R index 9a0edd4..00434bb 100644 --- a/R/recode_locations.R +++ b/R/recode_locations.R @@ -83,7 +83,7 @@ to_location_table_column <- function(location_format) { #' corresponding to a given location vector #' and format, with repeats possible #' @param location_vector vector of location values -#' @param location_format format in which the location +#' @param location_input_format format in which the location #' vector is coded. #' Permitted formats are `"abbr"` (state/territory #' or nation two letter USPS abbreviation), `"hub"` diff --git a/man/location_lookup.Rd b/man/location_lookup.Rd index d74fa5a..0ba19db 100644 --- a/man/location_lookup.Rd +++ b/man/location_lookup.Rd @@ -15,17 +15,17 @@ location_lookup( \arguments{ \item{location_vector}{vector of location values} -\item{location_output_format}{Return only this column of the -output table, if it is provided. Otherwise return the whole -table. Default \code{NULL} (return all columns). +\item{location_input_format}{format in which the location +vector is coded. +Permitted formats are \code{"abbr"} (state/territory or nation two letter USPS abbreviation), \code{"hub"} (legacy 2-digit FIPS code for states and territories, \code{US} for the USA as a whole), and \code{"long_name"} (full English name for jurisdiction).} -\item{location_format}{format in which the location -vector is coded. -Permitted formats are \code{"abbr"} (state/territory +\item{location_output_format}{Return only this column of the +output table, if it is provided. Otherwise return the whole +table. Default \code{NULL} (return all columns). or nation two letter USPS abbreviation), \code{"hub"} (legacy 2-digit FIPS code for states and territories, \code{US} for the USA as a whole), and \code{"long_name"} (full English From 0003d6d9b6776248a5ea344f28a9253dc4f04517 Mon Sep 17 00:00:00 2001 From: "Dylan H. Morris" Date: Wed, 20 Nov 2024 21:25:17 -0500 Subject: [PATCH 7/8] Fix pointinterval plot docs --- R/plot_hubverse_pointinterval.R | 15 ++++++--------- man/plot_hubverse_pointintervals.Rd | 19 +++++++++---------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/R/plot_hubverse_pointinterval.R b/R/plot_hubverse_pointinterval.R index 3ef6297..6ce7dce 100644 --- a/R/plot_hubverse_pointinterval.R +++ b/R/plot_hubverse_pointinterval.R @@ -4,15 +4,12 @@ #' @param hubverse_table Hubverse table, as a [`tibble`][tibble::tibble()] #' @param horizon horizons to plot, as a vector of integers. If `NULL`, #' plot all available, each in its own facet. Default `NULL`. -#' @param locations set of locations to plot. If NULL, -#' all locations are plotted. Otherwise, a vector -#' of location values to plot, as USPS-style -#' abbreviations (e.g. `c("US", "AL", "AK"`), -#' US hubverse submission location codes ( -#' e.g. `c("US", 01, 02)`), or full English -#' jurisdiction names -#' (e.g. `c("United States, "Alabama", "Alaska")`. -#' Default `NULL`. +#' @param point_estimate_quantile Quantile to plot as the point estimate. +#' Default `0.5`, the median. +#' @param lower_limit_quantile Quantile to plot as the lower bound of +#' the interval. Default `0.025`. +#' @param upper_limit_quantile Quantile to plot as the upper bound of +#' the interval. Default `0.975`. #' @param location_column_format format of the hubverse table #' `location` column. #' Permitted formats are `"abbr"` (state/territory diff --git a/man/plot_hubverse_pointintervals.Rd b/man/plot_hubverse_pointintervals.Rd index 91d5f5e..942311e 100644 --- a/man/plot_hubverse_pointintervals.Rd +++ b/man/plot_hubverse_pointintervals.Rd @@ -18,6 +18,15 @@ plot_hubverse_pointintervals( \arguments{ \item{hubverse_table}{Hubverse table, as a \code{\link[tibble:tibble]{tibble}}} +\item{point_estimate_quantile}{Quantile to plot as the point estimate. +Default \code{0.5}, the median.} + +\item{lower_limit_quantile}{Quantile to plot as the lower bound of +the interval. Default \code{0.025}.} + +\item{upper_limit_quantile}{Quantile to plot as the upper bound of +the interval. Default \code{0.975}.} + \item{location_output_format}{how to code locations in the output plot. Permitted formats are \code{"abbr"} (state/territory or nation two letter USPS abbreviation), \code{"hub"} ( @@ -28,16 +37,6 @@ jurisdiction names). Default \code{"abbr"}.} \item{horizon}{horizons to plot, as a vector of integers. If \code{NULL}, plot all available, each in its own facet. Default \code{NULL}.} -\item{locations}{set of locations to plot. If NULL, -all locations are plotted. Otherwise, a vector -of location values to plot, as USPS-style -abbreviations (e.g. \verb{c("US", "AL", "AK"}), -US hubverse submission location codes ( -e.g. \code{c("US", 01, 02)}), or full English -jurisdiction names -(e.g. \verb{c("United States, "Alabama", "Alaska")}. -Default \code{NULL}.} - \item{location_column_format}{format of the hubverse table \code{location} column. Permitted formats are \code{"abbr"} (state/territory From 3d80ea7270118a74d7ac1bc9266c25e5f1a43dfd Mon Sep 17 00:00:00 2001 From: "Dylan H. Morris" Date: Wed, 20 Nov 2024 21:30:49 -0500 Subject: [PATCH 8/8] More pointinterval docs fixes --- R/plot_hubverse_pointinterval.R | 6 +++--- man/plot_hubverse_pointintervals.Rd | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/R/plot_hubverse_pointinterval.R b/R/plot_hubverse_pointinterval.R index 6ce7dce..abe0a4a 100644 --- a/R/plot_hubverse_pointinterval.R +++ b/R/plot_hubverse_pointinterval.R @@ -2,7 +2,7 @@ #' as pointintervals #' #' @param hubverse_table Hubverse table, as a [`tibble`][tibble::tibble()] -#' @param horizon horizons to plot, as a vector of integers. If `NULL`, +#' @param horizons horizons to plot, as a vector of integers. If `NULL`, #' plot all available, each in its own facet. Default `NULL`. #' @param point_estimate_quantile Quantile to plot as the point estimate. #' Default `0.5`, the median. @@ -10,14 +10,14 @@ #' the interval. Default `0.025`. #' @param upper_limit_quantile Quantile to plot as the upper bound of #' the interval. Default `0.975`. -#' @param location_column_format format of the hubverse table +#' @param location_input_format Format of the hubverse table #' `location` column. #' Permitted formats are `"abbr"` (state/territory #' or nation two letter USPS abbreviation), `"hub"` ( #' legacy 2-digit FIPS code for states and territories, `US` #' for the USA as a whole), and `"long_name"` (full English #' jurisdiction names; not recommended). Default `"hub"`. -#' @param location_output_format how to code locations in the output plot. +#' @param location_output_format How to code locations in the output plot. #' Permitted formats are `"abbr"` (state/territory #' or nation two letter USPS abbreviation), `"hub"` ( #' legacy 2-digit FIPS code for states and territories, `US` diff --git a/man/plot_hubverse_pointintervals.Rd b/man/plot_hubverse_pointintervals.Rd index 942311e..d77f6eb 100644 --- a/man/plot_hubverse_pointintervals.Rd +++ b/man/plot_hubverse_pointintervals.Rd @@ -18,6 +18,9 @@ plot_hubverse_pointintervals( \arguments{ \item{hubverse_table}{Hubverse table, as a \code{\link[tibble:tibble]{tibble}}} +\item{horizons}{horizons to plot, as a vector of integers. If \code{NULL}, +plot all available, each in its own facet. Default \code{NULL}.} + \item{point_estimate_quantile}{Quantile to plot as the point estimate. Default \code{0.5}, the median.} @@ -27,23 +30,20 @@ the interval. Default \code{0.025}.} \item{upper_limit_quantile}{Quantile to plot as the upper bound of the interval. Default \code{0.975}.} -\item{location_output_format}{how to code locations in the output plot. +\item{location_input_format}{Format of the hubverse table +\code{location} column. Permitted formats are \code{"abbr"} (state/territory or nation two letter USPS abbreviation), \code{"hub"} ( legacy 2-digit FIPS code for states and territories, \code{US} -#' for the USA as a whole), and \code{"long_name"} (full English -jurisdiction names). Default \code{"abbr"}.} - -\item{horizon}{horizons to plot, as a vector of integers. If \code{NULL}, -plot all available, each in its own facet. Default \code{NULL}.} +for the USA as a whole), and \code{"long_name"} (full English +jurisdiction names; not recommended). Default \code{"hub"}.} -\item{location_column_format}{format of the hubverse table -\code{location} column. +\item{location_output_format}{How to code locations in the output plot. Permitted formats are \code{"abbr"} (state/territory or nation two letter USPS abbreviation), \code{"hub"} ( legacy 2-digit FIPS code for states and territories, \code{US} -for the USA as a whole), and \code{"long_name"} (full English -jurisdiction names; not recommended). Default \code{"hub"}.} +#' for the USA as a whole), and \code{"long_name"} (full English +jurisdiction names). Default \code{"abbr"}.} } \value{ A ggplot2 plot of the forecasts as pointintervals