From 2d4509a4adfb3ff7711fc11a43887959516c3ce3 Mon Sep 17 00:00:00 2001 From: Richard Li Date: Wed, 14 Aug 2024 11:47:54 -0700 Subject: [PATCH] make compareEstimates() return ggplot object --- R/smoothArea.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/R/smoothArea.R b/R/smoothArea.R index 63d16aa..20eedfc 100644 --- a/R/smoothArea.R +++ b/R/smoothArea.R @@ -427,6 +427,7 @@ plot.svysae <- function(x, return_list = F, plot.factor = NULL, ...) { #' @param x an object in the S3 class of svysae, fhModel, or clusterModel. Plots are created for all models in this object. #' @param posterior.sample Matrix of posteriors samples of area level quantities with one row for each area and one column for each sample. This argument may be specified to only provide a heatmap for the desired samples. #' @param title Optional parameter changing the title of the plot +#' @param return.plot Logical indicator for whether the ggplot object is returned #' #' @return ggplot containing heat map of pairwise comparisons #' @@ -454,7 +455,8 @@ plot.svysae <- function(x, return_list = F, plot.factor = NULL, ...) { #' } compareEstimates <- function(x, posterior.sample = NULL, - title = NULL) { + title = NULL, + return.plot = FALSE) { x_att <- attributes(x) @@ -545,6 +547,7 @@ compareEstimates <- function(x, } else if (is.null(posterior.sample)) { g_heat <- g_heat + ggplot2::labs(title = x_att$inla.fitted[i]) } + if(return.plot) return(g_heat) suppressWarnings(print(g_heat)) } }