#' Get ggplot to visualize output from \code{\link{mean_comparisons.predict_the_past_model_bh_GxE}}
#'
#' @description
#' \code{plot.mean_comparisons_predict_the_past_model_bh_GxE} returns ggplot to visualize outputs from \code{\link{mean_comparisons.predict_the_past_model_bh_GxE}}
#'
#' @param x Output from \code{\link{mean_comparisons.predict_the_past_model_bh_GxE}}
#'
#' @param plot_type "interaction", "barplot" or "score"
#'
#' @param nb_parameters_per_plot number of parameter per plot to display
#'
#' @param ... further arguments passed to or from other methods
#'
#' @details
#' S3 method.
#' See example in the book: https://priviere.github.io/PPBstats_book/family-2.html#model-2
#'
#' @return
#' It is the same outputs than for \code{\link{plot.mean_comparisons_model_bh_intra_location}}
#'
#' @author Pierre Riviere
#'
#' @seealso \code{\link{mean_comparisons.predict_the_past_model_bh_GxE}}
#'
#' @export
#'
plot.mean_comparisons_predict_the_past_model_bh_GxE <- function(
x,
plot_type = "interaction",
nb_parameters_per_plot = 8, ...
){
parameter_statuts = NULL # to avoid no visible binding for global variable
x = list(
"data_mean_comparisons" = x[[1]],
"data_env_with_no_controls" = NULL,
"data_env_whose_param_did_not_converge" = NULL
)
attributes(x)$PPBstats.object = "mean_comparisons_model_bh_intra_location"
if(plot_type == "score" | plot_type == "interaction") {
ylab = paste(
x$data_mean_comparisons[[1]]$mean.comparisons$entry,
" (",
x$data_mean_comparisons[[1]]$mean.comparisons$parameter_statuts,
")", sep = ""
)
x$data_mean_comparisons[[1]]$mean.comparisons$entry = ylab
}
out = plot.mean_comparisons_model_bh_intra_location(x, plot_type, nb_parameters_per_plot)
if(plot_type == "barplot") {
p1 = lapply(out$data_mean_comparisons[[1]], function(x){ x + geom_bar(aes(fill = parameter_statuts), stat = "identity") } )
out$data_mean_comparisons[[1]] = p1
}
out = out[1]
return(out)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.