我正在用R-markdown生成PowerPoint演示文稿。如何在幻灯片上包含多个图形或“内容”?

我尝试将PowerPoint模板修改为包括以下三个内容块:

但是我无法向右下角的对象添加内容。

---
title: "pp_test"
output:
  powerpoint_presentation:
    reference_doc: pp_template3.pptx
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

# Slide with 3 contents

:::::::::::::: {.columns}
::: {.column}
Text
:::
::: {.column}
```{r pressure, echo=FALSE, fig.cap="Caption"}
plot(pressure)
```
:::
::: {.column}
```{r cars, echo = TRUE}
summary(cars)
```
:::
::::::::::::::


我希望将“摘要(汽车)”部分添加到幻灯片上的图下方,但将其排除在外。

最佳答案

我无法成功使用r-markdown,因此我研究了其他软件包并找到了“军官”,这些人可以产生我想要的结果。

它不支持不是数据框的表,因此我无法添加“摘要(汽车)”部分。但是以两个图为例,我能够得出结果


使用以下代码

library(officer)
library(magrittr)
library(ggplot2)
setwd(mydir)

my_plot <- ggplot(data=pressure) +
  geom_point(aes(temperature, pressure))
my_summary <- as.str(summary(cars))

my_pres <-
  read_pptx("pp_template3.pptx") %>%
  add_slide(layout = "Two Content", master = "Office Theme") %>%
  ph_with_text(type = "title", index = 1, str = "The title") %>%
  ph_with_gg(type = "body", index = 1, value = my_plot) %>%
  ph_with_text(type = "body", index = 2, str = "Some text") %>%
  ph_with_gg(type = "body", index = 3, value = my_plot) %>%
  print(target = "test_pp_officer.pptx") %>%
  invisible()

关于r - 如何在RMarkdown的PowerPoint幻灯片中包含多个图形?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56309247/

10-13 01:14