Read PowerPoint into R

2019-07-18 07:55发布

Is it possible to import PowerPoint files into R? I saw that you can use the ReporteRs package to create and manipulate powerpoint files, but I couldnt find anything on importing them.

I was hoping that I could load a pptx into an object like.

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

and then merge them into one file

pptx1<-addslide(pptx2,..)

Background: I would like to create a reporting tool based on slides from many different powerpoint files and since I am very bad at VBA, I was hoping that R could be a good alternative.

标签: r reporters
1条回答
啃猪蹄的小仙女
2楼-- · 2019-07-18 08:42

maybe too late but package officer can import data from pptx or docx file in a tidy format:

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>
查看更多
登录 后发表回答