Renders a ggplot to an image and places it in the current slide's content placeholder (pptx) or as a new figure (docx).
Arguments
- doc
A document from
report_new().- plot
A ggplot object (any grid grob also works, e.g. an aligned plot from
report_deck()'s alignment step).- width, height
Image size in inches.
NULL(default) sizes the image to the slide's content placeholder (pptx) or6 x 3.5(docx), so charts fill whatever template the deck is built on.- dpi
Raster resolution. Defaults to
150.
Details
On slides the image is rendered at exactly the content placeholder's size, so nothing is stretched or letterboxed; when the template does not define placeholder geometry the slide size (minus margins) is used instead.
Examples
# \donttest{
p <- calc_percentage(podracing_survey, demo_gender) %>% plot_bars()
doc <- report_new("pptx") %>%
report_add_slide("Gender") %>%
report_add_plot(p)
class(doc)
#> [1] "rpptx"
# }
