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?
To transform your markdown file into an HTML, PDF, or Word document, click the “Knit” icon that appears above your file in the scripts editor. A drop down menu will let you select the type of output that you want. When you click the button, rmarkdown will duplicate your text in the new file format.
RMarkdown is an extension to markdown which includes the ability to embed code chunks and several other extensions useful for writing technical reports. The rmarkdown package extends the knitr package to, in one step, allow conversion between an RMarkdown file (.Rmd) into PDF, HTML, word document, amongst others.
Actually, the knit button can indeed -
Example with output directory called output
:
title: "multiple outputs"
output:
word_document: default
html_document: default
knit: (function(inputFile, encoding) {
rmarkdown::render(inputFile, encoding = encoding,
output_dir = "output", output_format = "all") })
Yes it's possible to render multiple outputs, but not with the "knit" Button in RStudio. Write your desired output in the YAML header and then use output_format = "all"
as argument in
rmarkdown::render(<your-rmd-file.rmd>, output_format ="all")
So the YAML header looks like:
title: "multiple outputs"
output:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With