我试图将一系列子弹点写入同一幻灯片,并使用以下R代码:
library(officer)
library(magrittr)
ppt <- read_pptx()
ppt <- ppt %>%
add_slide(layout = "Title and Content", master = "Office Theme") %>%
ph_with_text(type = "title", str = "FFT power spectrum") %>%
ph_with_text(type = "body", str = "no visual discrimination") %>%
ph_add_par(level = 1L) %>%
ph_add_text(str = "whole trajectories")
print(ppt, target = "test.pptx") %>% invisible()
......失败了,说......
Error in doc_parse_raw(x, encoding = encoding, base_url = base_url, as_html = as_html, :
Premature end of data in tag p line 1 [77]
当我将level-parameter更改为
时ph_add_par(level = 2L)
它工作得很好(如小插图所示:https://cran.r-project.org/web/packages/officer/vignettes/powerpoint.html)
我在这里缺少什么?
答案 0 :(得分:1)
这是一个错误,感谢报道。您可以使用devtools::install_github("davidgohel/officer")
获取开发版本。
在略微修改的脚本之下:
library(officer)
library(magrittr)
default_font <- fp_text(font.family = "Calibri", font.size = 0)
ppt <- read_pptx()
ppt <- ppt %>%
add_slide(layout = "Title and Content", master = "Office Theme") %>%
ph_with_text(type = "title", str = "FFT power spectrum") %>%
ph_with_text(type = "body", str = "no visual discrimination") %>%
ph_add_par(level = 1L, type = "body") %>%
ph_add_text(str = "whole trajectories", type = "body", style = default_font )
print(ppt, target = "test.pptx") %>% browseURL()