Convert docx to Rmarkdown
Asked Answered
C

1

6

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.

Cassel answered 30/3, 2017 at 8:36 Comment(1)
not sure what's the difference between rmarkdown and pandoc markdown, but you could probably write a pandoc filter to make the necessary changes. Regarding importing word corrections, use the --track-changes flag.Pelage
I
5

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"))
Incommunicative answered 8/1, 2020 at 20:13 Comment(2)
How can we retain the formatting in the .docx?Unreserved
Has this been outdated by the URL failing? Can someone update it?Welles

© 2022 - 2024 — McMap. All rights reserved.