The output filename will be different for each state. You can also make use of the state
variable in the document input.Rmd
, e.g.,
The former (clean
) is particularly helpful for debugging when anything goes wrong with the Pandoc conversion. If you call rmarkdown::render(..., clean = FALSE)
, all intermediate files will be preserved, including the intermediate .md
file knitted from the .Rmd
file. If Pandoc signals an error, you may start debugging from this .md
file.
This method is similar to clicking the Knit
button in RStudio, which also renders the Rmd document in a new R session. In case you need to render an Rmd document inside another Rmd document, we strongly recommend that you use this method instead of directly calling rmarkdown::render()
in a code chunk, because rmarkdown::render()
creates and relies on a lot of side effects internally, which may affect rendering other Rmd documents in the same R session.