#' Plot Boxes
#'
#'Plots boxplots of median estimates across simulations by runsetting. Runsetting is listed across the x axis, the truth is
#'shown by dotted black line (the given value from simulated data). The distribution of median estimates are plotted using a box plot.
#'
#' @param df The dataframe that has summary estimates by simulation and by runsetting DFtot.RDS saved in the output folder.
#' @param pars Vector of plotting parameters.
#'
#' @return Box plots of median estimates by runsetting. Saved to figure directory fig.dir.
#' @export
#'
#' @examples
#' plot_box(df = df, pars = "sensworld)
#'
plot_box <- function(df, pars) {
# test function to see if the input data has the correct format
if ("median" %in% names(df))
{
g <-ggplot(df, aes(y = median, x = factor(runsetting), color=factor(runsetting))) +
geom_boxplot(width = 0.25, fill = "white") +
labs(x = "", y = "Average Median", title = "Distribution of Median Estimates") +
theme(
text = element_text(size = 18),
axis.text.x = element_blank(),
plot.title = element_text(hjust = 0.5))+
facet_wrap(~parameter, ncol = 3, scales = "free_y") +
geom_hline(data = df,aes(yintercept = truth),
linetype = "dashed",
color = "black") + theme_classic()
g1 <- g + theme(legend.position="none")
print(g1)
}
else{
stop(cat(
paste0(pars),
(
"parmeter cannot be plotted. Check if the dataset contains median"
)
), call. = FALSE)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.