2017-08-11 25 views
0

我想要的要點的順序寫在同一張幻燈片,用下面的R-代碼:官 - 錯誤添加水平1款到時現有幻燈片

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] 

當我改變級別參數

ph_add_par(level = 2L) 

它工作得很好(如證明小插曲:https://cran.r-project.org/web/packages/officer/vignettes/powerpoint.html

我在這裏錯過了什麼?

回答

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()