I'm trying to efficiently save multiple graphs for an upcoming manuscript. My code isn't working, but I'm at a loss as to why...any help would be appreciated!
# Create list one, the list of objects figs = list(plot_1=ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point(), plot_2=ggplot(faithful, aes(waiting, eruptions))+ geom_point()+ stat_ellipse()) # create list 2, the list of file names fig_names = figs |> names() |> map(paste0, ".png") # pass both to purrr to use ggsave iteratively over both lists once and save all graphs with one command walk2(figs, fig_names, ~ggsave(plot = figs, filename = fig_names, path=here::here("Figures and Tables"), device = "png", dpi = 300))
The script "saves" plot_1, but it this png file is actually blank when I open it. Also, it doesn't save the second plot and gives me the following error: Error in UseMethod("grid.draw") : no applicable method for grid.draw applied to an object of class "list"