Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
201 views
in Technique[技术] by (71.8m points)

R: In RStudio how do I make knitr output to a different folder to avoid cluttering up my drive?

I am using RStudio's knit HTMl function to output some presentations. But it always outputs the files to my current work directory. How can I make it output to another directory so that my directory is clean with only the original .rmd files?

question from:https://stackoverflow.com/questions/26174565/r-in-rstudio-how-do-i-make-knitr-output-to-a-different-folder-to-avoid-clutteri

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As Eric pointed out in the comments, if you're willing to forego the convenience of the Knit HTML button (which produces HTML files that live alongside your .Rmd), you can just call rmarkdown::render directly.

However, if you really need to customize your workflow, you can override the Knit HTML button to run whatever command you via the rstudio.markdownToHTML option. This command could invoke rmarkdown with specific options (such as output directory) and perform other pre- or post-processing tasks. Documentation here:

https://support.rstudio.com/hc/en-us/articles/200552186-Customizing-Markdown-Rendering

Note that setting the rstudio.markdownToHTML option will turn off some of the newer RMarkdown V2 integration features baked into RStudio, since RStudio will no longer be able to infer what engine is being used to render the document.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...