【发布时间】:2017-04-16 16:35:18
【问题描述】:
我正在尝试将来自 knitr 输出的 PNG 图作为单独的文件写入磁盘,而无需手动执行。
我尝试了什么
-
http://gforge.se/2014/01/fast-track-publishing-using-knitr-part-iii/ 中的
dev = 'png'设置(this question 中也提到过) -
self_contained: no来自knitr: include figures in report *and* output figures to separate files。
都没有用。运行编织过程的文件夹没有多余的文件,HTML 文档的源代码中嵌入了 base64 图像。
环境
- RStudio 0.99.903
- R 3.2.3
- knitr 1.15.1
MWE:RStudio RMarkdown 文件,添加了上述选项:
---
title: "Untitled"
output: html_document
self_contained: no
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(dev="png",
dev.args=list(type="cairo"),
dpi=96)
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars}
summary(cars)
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
【问题讨论】: