R/multiplot.R

Defines functions multiplot

Documented in multiplot

#' Plot Multiple bcea Graphs
#' 
#' Arrange plots in grid. Sourced from R graphics cookbook.
#' 
#' @param plotlist List of ggplot objects
#' @param cols Number of columns
#' @param layout_config Matrix of plot configuration
#' @return ggplot TableGrob object
#' 
#' @importFrom gridExtra grid.arrange
#' @keywords internal
#' 
multiplot <- function(plotlist = NULL,
                      cols = 1,
                      layout_config = NULL) {
  
  n_plots <- length(plotlist)
  
  layout_config <-
    layout_config %||% matrix(seq(1, cols*ceiling(n_plots/cols)),
                              ncol = cols,
                              nrow = ceiling(n_plots/cols))
  
  grid_params <-
    c(plotlist, list(layout_matrix = layout_config))
  
  do.call("grid.arrange", grid_params)
}

Try the BCEA package in your browser

Any scripts or data that you put into this service are public.

BCEA documentation built on Nov. 25, 2023, 5:08 p.m.