Read PowerPoint into R

倾然丶 夕夏残阳落幕 提交于 2019-12-11 01:11:12

问题


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.


回答1:


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>


来源:https://stackoverflow.com/questions/39162473/read-powerpoint-into-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!