Paul
Paul

Reputation: 117

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.

Upvotes: 7

Views: 4608

Answers (1)

mattador
mattador

Reputation: 481

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"))

Upvotes: 6

Related Questions