epi_plot_cow_save: Save a grid of plots

View source: R/epi_plot_cow_save.R

epi_plot_cow_saveR Documentation

Save a grid of plots

Description

epi_plot_cow_save() A light wrapper to save plots to disk with cowplot::save_plot()

Usage

epi_plot_cow_save(
  file_name = NULL,
  plot_grid = NULL,
  base_height = 11.69,
  base_width = 8.27,
  ...
)

Arguments

file_name

Name of the file to save

plot_grid

plot to save, more often expecting a grid.

base_height

Height in inches of the plot. Default is 11.69 (A4 size)

base_width

Width in inches of the plot. Default is 8.27 (A4 size)

...

Pass any other parameter from cowplot::save_plot()

Value

None, file saved to disk.

Note

height and width are for A4 size. See also ggplot2 wrappers epi_plot_*().

Author(s)

Antonio Berlanga-Taylor <\url{https://github.com/AntonioJBT/episcout}>

See Also

epi_plot_list, epi_plots_to_grid, plot_grid, save_plot.

Examples


## Not run: 
set.seed(12345)
n <- 20
df <- data.frame(var_id = rep(1:(n / 2), each = 2),
                 var_to_rep = rep(c("Pre", "Post"), n / 2),
                 x = rnorm(n),
                 y = rbinom(n, 1, 0.50),
                 z = rpois(n, 2)
)
df
df[, 'var_id'] <- as.character(df[, 'var_id'])
vars_to_plot <- df %>%
  select_if(epi_clean_cond_numeric) %>%
  names()
my_plot_list <- epi_plot_list(vars_to_plot)
my_plot_list
# Generate plots:
for (i in names(my_plot_list)) {
  print(i)
  my_plot_list[[i]] <- ggplot2::ggplot(df, aes_string(y = i)) + geom_boxplot()
}
# Pass to a grid and save to file:
# length(my_plot_list)
my_plot_grid <- epi_plots_to_grid(my_plot_list[1:length(my_plot_list)])
epi_plot_cow_save(file_name = 'plots_1.pdf', plot_grid = my_plot_grid)


## End(Not run)


AntonioJBT/episcout documentation built on Dec. 1, 2024, 4:07 a.m.