steinbock steinbock - 1 year ago 108
Markdown Question

Knit one markdown file to two output files

Is there a way to knit a single .md file to a .html or .docx in the working directory in R and simultaneously post a copy of the .html to another folder, possibly on another drive?

Alternatively, can the 'publish' button in RStudio be used to send a .md file to a location other than RPubs?

Answer Source

Yes it's possible to render multiple output, but not with the "knit" Button in RStudio. Write your desired output in the YAML header an then use output_format = "all" as argument in

rmarkdown::render(<your-rmd-file.rmd>, output_format ="all")

So the YAML header look like:

title: "multiple outputs"
     word_document: default
     html_document: default

Or any option you want to set for the different output formats.

I don't know if it is possible to set different output directories, but I don't think so.