Using header of chunk to save plot

半腔热情 提交于 2020-01-04 15:14:29

问题


So I've been searching for an answer for this, and haven't really found anything. I'm hoping there isn't anything like this already on the board so I don't waste anyone's time. In the recent upgrade of I'm assuming RStudio, a method I used to save plots went away. Below is an example chunk of what it looks like:

```{r dummy, dev=c('png', 'pdf'), fig.height=4, fig.width=6}

x = 1:10
y = 10:1

plot(x,y)
```

The code will still compile when I do this. However, when I knit my code in order to save the plots, it does not save the plots. Is there a way similar to this that is compatible with the updated RStudio/knitr? Thanks for the help!


回答1:


you can add the self_contained: no option in the html_document output front matter section at the top of your Rmd. but the images are embedded in the html so you dont really need the images folder – rawr

EDIT:

like so:

---
output:
  html_document:
    self_contained: no
    <other options>
---

res of knitr document...

this will generate a couple new directories and within the "figure-html" one, you can find the images.



来源:https://stackoverflow.com/questions/24857264/using-header-of-chunk-to-save-plot

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!