将PowerPoint读入R

时间:2016-08-26 09:05:12

标签: r reporters

是否可以将PowerPoint文件导入R? 我看到你可以使用ReporteRs包来创建和操作powerpoint文件,但我无法找到任何导入它们的东西。

我希望我可以将pptx加载到像这样的对象中。

pptx1<-read.ppt(file1)
pptx2<-read.ppt(file2)

然后将它们合并到一个文件中

pptx1<-addslide(pptx2,..)

背景:我想基于来自许多不同powerpoint文件的幻灯片创建一个报告工具,因为我在VBA非常糟糕,我希望R可能是一个不错的选择。

1 个答案:

答案 0 :(得分:0)

可能为时已晚,但包officer可以以整齐的格式从pptx或docx文件导入数据:

example_pptx <- system.file(package = "officer", "doc_examples/example.pptx")
doc <- read_pptx(example_pptx)
content <- pptx_summary(doc)
content

# A tibble: 29 x 9
                text    id content_type slide_id row_id cell_id col_span
               <chr> <chr>        <chr>    <int>  <int>   <int>    <dbl>
 1             Title    12    paragraph        1     NA      NA       NA
 2          A table     13    paragraph        1     NA      NA       NA
 3     and some text    13    paragraph        1     NA      NA       NA
 4 and some list (1)    13    paragraph        1     NA      NA       NA
 5 and some list (2)    13    paragraph        1     NA      NA       NA
 6         Header 1     18   table cell        1      1       1        1
 7          Header 2    18   table cell        1      1       2        1
 8          Header 3    18   table cell        1      1       3        1
 9                 A    18   table cell        1      2       1        1
10             12.23    18   table cell        1      2       2        1
# ... with 19 more rows, and 2 more variables: row_span <dbl>,
#   media_file <chr>