r - 如何在 RMarkdown 的 PowerPoint 幻灯片中包含多个数字?
问题描述
我正在使用 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 无法成功,所以我研究了其他包并找到了“officer”,它能够产生我想要的结果。
它不支持不是数据框的表,因此我无法添加“摘要(汽车)”部分。但是以两个图为例,我能够产生结果
使用以下代码
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()
推荐阅读
- mongodb - MongoDB 聚合查询执行缓慢
- mysql - 用于将特定列与同一列的平均值进行比较的 SQL 查询
- android - MPAndroidChart LineChart 未正确绘制
- r - 将派对包用于决策树图时,导致此错误消息的原因是什么?
- python - 从日期时间中去除微秒
- android - 如何让这个 ViewModelFactory 更灵活并接受不同种类的 ViewModel 类?
- api - DocuSign API - 在每个文档的末尾添加签名页面
- angular - 如何将第三个状态添加到复选框?
- html - 为什么 input[type=checkbox] 不允许 CSS?
- ios - 由图像视图剪辑到边界的 CAShapeLayer