From a24b0429b19a17b01e2e1c2eadb8d4cf58acdbad Mon Sep 17 00:00:00 2001 From: "George G. Vega Yon" Date: Tue, 29 Aug 2023 15:21:59 -0600 Subject: [PATCH] Fixing GHA (plot run_multipl) --- R/make_saver.R | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/R/make_saver.R b/R/make_saver.R index 20ef322f..442f9680 100644 --- a/R/make_saver.R +++ b/R/make_saver.R @@ -151,16 +151,27 @@ run_multiple_get_results <- function(m) { # Putting all together output[[i]] <- do.call(rbind, output[[i]]) - # runif - # - # runif(10, min=2, max=4) - # do.call(runif, list(10, 2, 4)) - # - # rbind(output[[i]][[1]], output[[i]][[2]], ...) - - class(output[[i]]) <- c("epiworld_multiple_save_i", class(output[[i]])) + # If there are no observations, then + err_msg <- tryCatch({ + class(output[[i]]) <- c("epiworld_multiple_save_i", class(output[[i]])) + }, error = function(e) e + ) + + if (inherits(err_msg, "error")) { + + warning( + "When retrieving the saved results, for the case of ", + i, ", there were no observations." + ) + + class(output[[i]]) <- structure( + data.frame(), + c("epiworld_multiple_save_i") + ) + + } + attr(output[[i]], "what") <- i - } @@ -180,6 +191,14 @@ plot.epiworld_multiple_save <- function(x, y = NULL, ...) { plot.epiworld_multiple_save_i <- function(x, y = NULL, ...) { what <- attr(x, "what") + + if (nrow(x) == 0) { + warning( + "When plotting the saved results, for the case of ", + what, ", there were no observations." + ) + return(NULL) + } # If it is not reproductive number, then... if (what != "reproductive") {