From 16f6c2c5da3fb906b0152348c29a328ada0ace55 Mon Sep 17 00:00:00 2001 From: "Daniel J. McDonald" Date: Mon, 25 Sep 2023 10:04:36 -0700 Subject: [PATCH] example plotting with ggplot2 handled correctly --- R/layer_cdc_flatline_quantiles.R | 4 ++-- R/make_smooth_quantile_reg.R | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/R/layer_cdc_flatline_quantiles.R b/R/layer_cdc_flatline_quantiles.R index 1881b8523..7ff224359 100644 --- a/R/layer_cdc_flatline_quantiles.R +++ b/R/layer_cdc_flatline_quantiles.R @@ -75,7 +75,7 @@ #' pivot_quantiles(.pred_distn) %>% #' mutate(target_date = forecast_date + ahead) #' -#' library(ggplot2) +#' if (require("ggplot2")) { #' four_states <- c("ca", "pa", "wa", "ny") #' preds %>% #' filter(geo_value %in% four_states) %>% @@ -92,7 +92,7 @@ #' facet_wrap(~geo_value, scales = "free_y") + #' theme_bw() + #' geom_vline(xintercept = forecast_date) -#' +#' } layer_cdc_flatline_quantiles <- function( frosting, ..., diff --git a/R/make_smooth_quantile_reg.R b/R/make_smooth_quantile_reg.R index 6eab2a132..cfb08a9c7 100644 --- a/R/make_smooth_quantile_reg.R +++ b/R/make_smooth_quantile_reg.R @@ -61,7 +61,8 @@ #' lines(pl$x, pl$`0.2`, col = "blue") #' lines(pl$x, pl$`0.8`, col = "blue") #' lines(pl$x, pl$`0.5`, col = "red") -#' \dontrun{ +#' +#' if (require("ggplot2")) { #' ggplot(data.frame(x = x, y = y), aes(x)) + #' geom_ribbon(data = pl, aes(ymin = `0.2`, ymax = `0.8`), fill = "lightblue") + #' geom_point(aes(y = y), colour = "grey") + # observed data