【发布时间】:2017-09-26 10:33:49
【问题描述】:
我正在使用 R markdown 编写一个相当长的代码,分为块。情节出现在适当的块下。我想保留这种行为,但另外我想将它们保存到指定的文件夹中。我尝试了此处列出的不同方法How to save a plot as image on the disk?(以及 Internet 上的其他地方),但似乎没有任何效果。
我的可重现示例:
png('cars_plot.png')
plot(cars)
dev.off()
此代码保存绘图,但不显示它(它只返回“null device 1”)。我也尝试过 dev.print 和 dev.copy,结果相同。
先感谢您!
澄清:我一个一个地运行我的块,我不想将我的结果转换为 pdf/html。所以knitr: include figures in report *and* output figures to separate files 或change where rmarkdown saves images generated by r code 不要回答我的问题。
【问题讨论】:
-
你试过在你的开发环境之外运行
plot(cars)函数吗? -
是的,重复。添加在您的 rmd 标头中使用选项
self_contained: no,文件将在单独的文件夹中可用。
标签: r plot save r-markdown show