R打包人员无法写到PowerPoint幻灯片。 Layout_properties确认字段ctrTitle存在,但slide_summary报告零行。
> pres<-read_pptx()
> add_slide(x=pres,layout='Title Slide', master="Office Theme")
pptx document with 1 slide(s)
Available layouts and their associated master(s) are:
layout master
1 Title Slide Office Theme
2 Title and Content Office Theme
3 Section Header Office Theme
4 Two Content Office Theme
5 Comparison Office Theme
6 Title Only Office Theme
7 Blank Office Theme
> ph_add_text(x=pres, type="ctrTitle", str= "This is the title")
Error: unvalid id 0 (1 slide(s))
>
字段在layout_properties中退出。
> layout_properties(x=pres, layout="Title Slide", master="Office Theme")
master_name name type id ph_label
9 Office Theme Title Slide dt 4 Date Placeholder 3
17 Office Theme Title Slide ftr 5 Footer Placeholder 4
27 Office Theme Title Slide sldNum 6 Slide Number Placeholder 5
35 Office Theme Title Slide ctrTitle 2 Title 1
36 Office Theme Title Slide subTitle 3 Subtitle 2
ph offx offy cx
9 <p:ph type="dt" sz="half" idx="10"/> 0.500000 6.951389 2.333333
17 <p:ph type="ftr" sz="quarter" idx="11"/> 3.416667 6.951389 3.166667
27 <p:ph type="sldNum" sz="quarter" idx="12"/> 7.166667 6.951389 2.333333
35 <p:ph type="ctrTitle"/> 0.750000 2.329861 8.500000
36 <p:ph type="subTitle" idx="1"/> 1.500000 4.250000 7.000000
cy
9 0.3993056
17 0.3993056
27 0.3993056
35 1.6076389
36 1.9166667
>
我试图链接命令;错误消息不同。
> pres<-read_pptx()
> add_slide(x=pres,layout="Title Slide", master="Office Theme") %>%
+ ph_add_text(type='ctrTitle',str="This is the title")
Error: selection does not match any row in slide_summary. Use function slide_summary.
>
这给了我一个线索。
> slide_summary(pres, index=1)
[1] type id ph_label offx offy cx cy text
<0 rows> (or 0-length row.names)
>
slide_summary报告零行。有人可以帮忙吗?
答案 0 :(得分:1)
这是我的工作代码。
pres <- read_pptx()
pres <- add_slide(pres, layout = "Title and Content", master = "Office Theme")
pres <- ph_empty(pres, type = "body")
pres <- ph_add_par(pres, level = 1)
pres <- ph_add_text(pres, str = "这里是文字")
而且我认为您应该考虑图书馆的事务。 然后可以这样写:
library("magrittr")
pres <- read_pptx() %>%
add_slide(layout = "Title and Content", master = "Office Theme") %>%
ph_empty(type = "body") %>%
ph_add_par(level = 1) %>%
ph_add_text(str = "这里是文字")
我看到您想要Title Slide
,那么您可以这样简单地写:
pres <- read_pptx() %>%
add_slide(layout = "Title Slide", master = "Office Theme") %>%
ph_with_text(type = "ctrTitle", str = "这里是文字")