gpt4 book ai didi

r - 为什么我不能将网格中的一组图发送到 PowerPoint with officer?

转载 作者:行者123 更新时间:2023-12-04 10:58:08 24 4
gpt4 key购买 nike

我已经使用 gridextra 创建了一个 qicharts2 图网格,但是当我尝试使用 officer 将它发送到 PowerPoint 时,我收到了这个错误。

doc_parse_raw(x, encoding = encoding, base_url = base_url, as_html = as_html, : StartTag:无效的元素名称[68]

这是我的代码:

library(qicharts2)
library(gridExtra)
library(officer)
library(rvg)



#24 random numbers from a normal distribution for example.
y1 <- rnorm(24)
y2 <- rnorm(24)

yC1 <- qic(y1)
yC2 <- qic(y2)

grid <- grid.arrange(yC1,yC2)


filename <- "C:\\Desktop\\MyCharts.pptx"


read_pptx(filename) %>%

add_slide(layout = "Title and Content", master = "Office Theme") %>%
ph_with_vg(code = print(grid), type = "body") %>%
print(target = filename) %>%
invisible()

非常感谢大家就如何改进我的问题提出的建议。

任何帮助都得到了进一步的帮助

最佳答案

当使用grid.arrange时,你正在绘图,打印方法在这里没有用(print(grid) had no effect on图形设备)。以下是使用 grid.arrange:

library(qicharts2)
library(gridExtra)
library(officer)
library(rvg)
library(magrittr)

#24 random numbers from a normal distribution for example.
y1 <- rnorm(24)
y2 <- rnorm(24)

yC1 <- qic(y1)
yC2 <- qic(y2)

read_pptx() %>%
add_slide(layout = "Title and Content", master = "Office Theme") %>%
ph_with_vg(code = grid.arrange(yC1,yC2), type = "body") %>%
print(target = "filename.pptx") %>%
browseURL()

编辑 rvg >= 0.2.4 :您必须使用 dml 函数:

read_pptx() %>% 
add_slide(layout = "Title and Content", master = "Office Theme") %>%
ph_with(value = dml(grid.arrange(yC1,yC2)), location = ph_location_type(type = "body")) %>%
print(target = "filename.pptx") %>%
browseURL()

关于r - 为什么我不能将网格中的一组图发送到 PowerPoint with officer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48407569/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com