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?
我正在使用RStudio的编织HTMl函数来输出一些演示文稿。但它总是将文件输出到我当前的工作目录。如何将其输出到另一个目录,以便我的目录是干净的,只有原始的.rmd文件?
2 个解决方案
#1
11
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.
正如Eric在评论中指出的那样,如果你愿意放弃Knit HTML按钮(它产生与你的.Rmd一起生成的HTML文件)的便利性,你可以直接调用rmarkdown :: render。
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:
但是,如果您确实需要自定义工作流程,则可以覆盖Knit HTML按钮以通过rstudio.markdownToHTML选项运行任何命令。此命令可以使用特定选项(例如输出目录)调用rmarkdown,并执行其他预处理或后处理任务。这里的文件:
https://support.rstudio.com/hc/en-us/articles/200552186-Customizing-Markdown-Rendering
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.
请注意,设置rstudio.markdownToHTML选项将关闭一些新的RMarkdown V2集成功能,因为RStudio将无法再推断用于呈现文档的引擎。
#2
8
The trick mentioned in Rmarkdown directing output file into a directory worked for me.
Rmarkdown中提到的把输出文件导入到我的目录中的技巧。
Example: Add the following to the YAML preamble as a top-level item to write output to the pdf/
subdirectory:
示例:将以下内容添加到YAML前导码作为*项目,以将输出写入pdf /子目录:
knit: (function(inputFile, encoding) {
rmarkdown::render(inputFile, encoding = encoding, output_dir = "pdf") })
#1
11
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.
正如Eric在评论中指出的那样,如果你愿意放弃Knit HTML按钮(它产生与你的.Rmd一起生成的HTML文件)的便利性,你可以直接调用rmarkdown :: render。
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:
但是,如果您确实需要自定义工作流程,则可以覆盖Knit HTML按钮以通过rstudio.markdownToHTML选项运行任何命令。此命令可以使用特定选项(例如输出目录)调用rmarkdown,并执行其他预处理或后处理任务。这里的文件:
https://support.rstudio.com/hc/en-us/articles/200552186-Customizing-Markdown-Rendering
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.
请注意,设置rstudio.markdownToHTML选项将关闭一些新的RMarkdown V2集成功能,因为RStudio将无法再推断用于呈现文档的引擎。
#2
8
The trick mentioned in Rmarkdown directing output file into a directory worked for me.
Rmarkdown中提到的把输出文件导入到我的目录中的技巧。
Example: Add the following to the YAML preamble as a top-level item to write output to the pdf/
subdirectory:
示例:将以下内容添加到YAML前导码作为*项目,以将输出写入pdf /子目录:
knit: (function(inputFile, encoding) {
rmarkdown::render(inputFile, encoding = encoding, output_dir = "pdf") })