The goal of tgppt is to provide handy functions to plot directly to powerpoint in R. It is based on the magnificent officer package from David Gohel.

Installation

You can install tgppt with:

remotes::install_github("tanaylab/tgppt")

Example

Plot base R directly to a powerpoint presentation:

library(tgppt)
#> 
#> Attaching package: 'tgppt'
#> The following object is masked from 'package:alutil':
#> 
#>     vertical_labs
temp_ppt <- tempfile(fileext = ".pptx")
plot_base_ppt({plot(mtcars$mpg, mtcars$drat)}, temp_ppt)

Plot ggplot to a powerpoint presentation:

library(tgppt)
library(ggplot2)
gg <- ggplot(mtcars, aes(x=mpg, y=drat)) + geom_point()
temp_ppt <- tempfile(fileext = ".pptx")
plot_gg_ppt(gg, temp_ppt)

Create a new powerpoint file:

library(tgppt)
new_ppt("myfile.pptx")

Use “Arial” font based ggplot theme:

ggplot2::theme_set(theme_arial(8))

Rasterize ggplot plotting area

Powerpoint might crash when plotting a large number of points. To avoid that, set rasterize_plot to TRUE:

plot_gg_ppt(gg, temp_ppt, rasterize_plot = TRUE)