Revised a second time!!
There is an example .rmd that comes with the officedown
package and in that are chunks that show how you can use the officer
package placeholder ("ph") tags within the chunk options, which is great. Here is a minimum reproducible example:
---
title: YAML Title
output:
officedown::rpptx_document
---
```{r echo=FALSE}
library(officedown)
```
## Slide 1 Title
```{r echo=FALSE, layout="Title and Content", ph=officer::ph_location_type(type="ftr")}
test <- data.frame(1)
test
```
The problem now is that if I try to insert a string instead of a data frame in the footer ("ftr"), then that string is instead placed in the body of the pptx slide, please see the example below.
---
title: YAML Title
output:
officedown::rpptx_document
---
```{r echo=FALSE}
library(officedown)
```
## Slide 1 Title
```{r echo=FALSE, layout="Title and Content", ph=officer::ph_location_type(type="ftr")}
"Some footer text"
```
And so now I'm very close but need help to get a string to appear in the footer. I tried a hack of making a single cell data frame with the string I want in that cell but that did not work either.
Thank you for reading!
Revised thanks to commenters!
I am trying to use officedown
combined with the officer
package to write out a footer to a slide. I thought to create a code chunk in the .Rmd with code that I know works in a .R script using officer
.
Using the example code below, it successfully creates 2 slides. However, on the second slide I would like to have a footer with the text "a footer". Instead on the second slide only the title appears. Is there a way to insert a footer using officedown
?
The reasons I thought it might be possible was after reading this on the officedown
page: "The package also enhances PowerPoint productions with R Markdown by providing a mechanism for placing results according to the slide template contained in the PowerPoint document used as "reference_doc" " - https://davidgohel.github.io/officedown/
Thank you for taking a look and here is the revised example code.
---
title: YAML Title
output:
officedown::rpptx_document
---
```{r setup, include=FALSE}
library(officedown)
library(officer)
```
## Slide 1 Title
```{r echo=FALSE}
my_pres <- read_pptx()
my_pres <- add_slide(my_pres, layout = "Title and Content", master = "Office Theme")
my_pres <- ph_with(my_pres, value = "a footer", location = ph_location_type(type = "ftr"))
```