Skip to content

Instantly share code, notes, and snippets.

@PaulC91
Created July 24, 2018 14:27
Show Gist options
  • Save PaulC91/855cd1b99b6b86d25976d15a13fd97db to your computer and use it in GitHub Desktop.
Save PaulC91/855cd1b99b6b86d25976d15a13fd97db to your computer and use it in GitHub Desktop.
Create multiple parameterised powerpoint reports using rmarkdown and purrr
library(rmarkdown)
library(ggplot2)
library(purrr)
ppt_render <- function (data) {
params <- list(data = data)
group <- unique(data$class)
rmarkdown::render("report.Rmd", output_file = paste0("mpg_", group, ".pptx"), params = params)
}
data_groups <- unique(mpg$class)
data_groups %>%
map(~ mpg %>% filter(class == .x)) %>%
walk(ppt_render)
---
title: "Create multiple PowerPoint Decks with `rmarkdowan` & `purrr`"
author: Paul Campbell
date: July 24, 2018
output: powerpoint_presentation
---
```{r plot, echo=FALSE}
library(ggplot2)
ggplot(params$data, aes(displ, hwy)) +
geom_point() +
labs(title = paste("Class:", unique(params$data$class)))
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment