Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert docx to Rmarkdown

My workflow looks involves producing Microsoft Word reports (using Rmarkdown) containing analysis of data. These reports are then reviewed and commented using Word's call-out comments feature. It's easier to make edits addressing the comments within the Word document, so that's what I do. I would now like to carry over these changes onto the Rmarkdown document. How can I do this?

Can I convert docx to Rmarkdown directly? I'm aware I can convert docx to markdown using Pandoc.

like image 983
Paul Avatar asked Oct 30 '22 10:10

Paul


1 Answers

Here's an example of converting from a .docx Word file to R markdown, and then to HTML.

require(rmarkdown);require(devtools)
examplefile=paste0(tempdir(),"/example.docx")
download.file("https://file-examples.com/wp-content/uploads/2017/02/file-sample_100kB.docx",destfile=examplefile)
pandoc_convert(examplefile,to="markdown",output = "example.rmd", options=c("--extract-media=."))

render(paste0(tempdir(), "/example.rmd"),"html_document")
browseURL(paste0(tempdir(),"/example.html"))
like image 142
mattador Avatar answered Nov 09 '22 07:11

mattador