r - 官员 r 包用于创建具有并排内容的幻灯片 - 内容仅出现在一个部分中
问题描述
R
尽管我尽了最大努力,但我无法在使用package生成的 Powerpoint 幻灯片中并排加载任何内容officer
。我想要的是内容(右侧的来源图像或情节等,左侧的文本)。这是我的工作流程:
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")
上述代码的结果是两条内容都出现在右侧。我可以在左侧以标题的形式获取文本,ph_with_text(type = "title", index=1, str = "title")
但尽管我尽了最大努力,但幻灯片的左侧没有出现标题或内容。
解决方案
您可以明确指定您的第一次调用ph_with
不会出现在右侧。
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")
推荐阅读
- reactjs - 如何用 Jest 测试这个 Redux Saga 代码?
- git - git pull 多个仓库
- javascript - Webpack 全局/process.env 变量范围?
- android - LINE 与联系人聊天
- node.js - 有什么方法可以访问另一条不同路线内的一条快速路线内的变量?
- python - 无效参数:TypeError:类型的对象
不能安全地解释为整数。回溯(最近一次通话最后): - vba - 统计签名中跳过图片的附件数量(基于 objAttachments.Item(s).Size)
- javascript - 范围输入最小值,最大值大整数数组排序得到此错误无法读取未定义的属性“替换”
- javascript - 在函数内反应 useEffect 陈旧值
- ssl - 如何使用 SASL_SSL 和 GSSAPI 协议配置 Kafka 服务器