Is there a way to save a ggplot twice to different file formats with just one ggsave command? E.g. plot.pdf and plot.png
You could use mapply() in this way:
mapply()
#Code mapply(function(x) ggsave(x,plot = Yourplot,width = 25, height = 18, units = 'cm'), x=c('plot.pdf','plot.png'))
An option with tidyverse would be
tidyverse
library(purrr) library(ggplot2) map(c('plot.pdf', 'plot.png'), ~ ggsave(.x, plot = Yourplot, width = 25, height = 18, units = 'cm'))
You could use
mapply()
in this way: