From 14632210043daef1bd762ad6ba172e09aebba8e4 Mon Sep 17 00:00:00 2001 From: nikosbosse Date: Wed, 6 Dec 2023 14:33:41 +0100 Subject: [PATCH] Add input checks to `plot_forecast_counts()` --- NAMESPACE | 1 + R/plot.R | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/NAMESPACE b/NAMESPACE index d44c528b8..d05f4258d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -86,6 +86,7 @@ importFrom(checkmate,assert_list) importFrom(checkmate,assert_logical) importFrom(checkmate,assert_number) importFrom(checkmate,assert_numeric) +importFrom(checkmate,assert_string) importFrom(checkmate,assert_vector) importFrom(checkmate,check_atomic_vector) importFrom(checkmate,check_data_frame) diff --git a/R/plot.R b/R/plot.R index 4d8d602e3..23894bafb 100644 --- a/R/plot.R +++ b/R/plot.R @@ -957,6 +957,7 @@ plot_pit <- function(pit, #' @importFrom ggplot2 ggplot scale_colour_manual scale_fill_manual #' geom_tile scale_fill_gradient .data #' @importFrom data.table dcast .I .N +#' @importFrom checkmate assert_string assert_logical #' @export #' @examples #' library(ggplot2) @@ -975,6 +976,10 @@ plot_forecast_counts <- function(forecast_counts, show_numbers = TRUE) { forecast_counts <- ensure_data.table(forecast_counts) + assert_string(y) + assert_string(x) + assert_logical(make_x_factor) + assert_logical(show_numbers) if (make_x_factor) { forecast_counts[, eval(x) := as.factor(get(x))]