编织器:将数字包括在报告中*和*输出数字以单独的文件 [英] knitr: include figures in report *and* output figures to separate files
问题描述
我不仅希望将数字显示在由knitr生成的报告中,而且还希望将它们输出到单独的文件中.为此,我包含了以下代码:
Not only would I like my figures to appear in my knitr-generated report, but I would also like to output them to separate files, too. To do this, I have included code like the following:
```{r}
#Plot figure in report
plot(x,y)
#Plot figure in file
pdf(file="MyFig.pdf")
plot(x,y)
dev.off()
```
这很好用,但是我希望对于已经内置在knitr中的解决方案,有一个更优雅的解决方案.是否有块选项或类似的选项可以达到相同的结果?
This works fine, but I expect there's a more elegant solution for this already built into knitr. Is there a chunk option or something similar that achieves the same results?
推荐答案
如果使用的是 pdf_document
),因此,rmarkdown不会在渲染输出文档后删除图形文件.
Use the option self_contained: no
if you are using html_document
, or keep_tex: yes
if you use pdf_document
, so that rmarkdown will not remove the figure files after rendering the output document.
这篇关于编织器:将数字包括在报告中*和*输出数字以单独的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!