View source: R/djpr_save_image.R
djpr_save_image | R Documentation |
This function is a wrapper around ggplot2::ggsave(). It is designed for saving plots as static images that will be then included in a DJPR PPTX deck.
djpr_save_image(
filename,
object = last_plot(),
size = c("full", "twothirds", "half", "quarter"),
remove_title = TRUE,
dpi = "retina"
)
filename |
name, including path and extension, of the file to be saved |
object |
name of the ggplot2 plot to be saved;
default is the last plot, using |
size |
size of picture. Options are: "full", "twothirds", "half" and "quarter" |
remove_title |
|
dpi |
resolution of picture. Default is 'retina' which is 320 dpi. |
Plots can be saved in pre-defined sizes: full slide, half slide, 2/3rds slide, and 1/4 slide, to fit the DJPR-SPP PowerPoint deck template.
The function removes the plot's title and subtitle by default, as these should be added on the slide itself rather than included in the image.
## Not run:
library(ggplot2)
p <- ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point()
djpr_save_image("test.png", p)
# Or to save an image in the right size to fill half a Powerpoint slide
djpr_save_image("test.png", p, size = "half")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.