Despite my best efforts, I cannot get any content loaded side by side in Powerpoint slides generated using the R
package officer
. What I would like is content (sourced images or plots, etc. on the right and text on the left). Here is my workflow:
plot.gg <- ggplot(iris, aes(Sepal.Length, Petal.Width)) +
geom_line()
library(officer)
read_pptx() %>%
add_slide(layout = "Two Content", master = "Office Theme") %>%
ph_with("text", location = ph_location_type(type = "body", index = 4)) %>%
ph_with(plot.gg, location = ph_location_type(type = "body", index = 3)) %>%
print(target = "test.pptx")
The result of the above code is that both pieces of content appear on the right flank. I can get text on the left side in the form of a title w/ ph_with_text(type = "title", index=1, str = "title")
but despite my best efforts no captions or content appears on the left hand side of the slide.
You can explicitly specify that your first call to ph_with
doesn't appear on the right.
read_pptx() %>%
add_slide(layout = "Two Content", master = "Office Theme") %>%
ph_with("text", location = ph_location_type(type = "body", index = 4, position_right = F)) %>%
ph_with(plot.gg, location = ph_location_type(type = "body", index = 3)) %>%
print(target = "test.pptx")