I would like to create a powepoint slide deck in rmarkdown by iteratively building the slides for each Day. See example below and code that makes a function to output the plots. I just don't know how to add these plots to a slide deck without saving and manually adding them in.
library(ggplot2)
library(tidyverse)
airquality<-datasets::airquality
glimpse(airquality)
vec<-unique(airquality$Day)
id=1
fctn<-function(id){
airquality_filtered<- airquality%>%filter(Day==id)
ggplot(airquality_filtered)+geom_point(aes(Ozone,Solar.R))+ggtitle(paste("Day",id))
ggsave(plot=last_plot(),paste("C:\\Users\\",id,"plot1.png"),width=6.25,height=3.75)
ggplot(airquality_filtered)+geom_line(aes(Ozone,Wind))+ggtitle(paste("Day",id))
ggsave(plot=last_plot(),paste("C:\\Users\\",id,"plot2.png"),width=6.25,height=3.75)
ggplot(airquality_filtered)+geom_point(aes(Ozone,Temp))+ggtitle(paste("Day",id))
ggsave(plot=last_plot(),paste("C:\\Users\\",id,"plot3.png"),width=6.25,height=3.75)
ggplot(airquality_filtered)+geom_bar(aes(Wind,Temp),stat='identity')+ggtitle(paste("Day",id))
ggsave(plot=last_plot(),paste("C:\\Users\\",id,"plot4.png"),width=6.25,height=3.75)
}
lapply(1:3,fctn)
This would be the desired output with a slide for each Day ie Day 1 (slide 1) Day 2 (slide 2) etc.