Using header of chunk to save plot

2019-07-18 18:20发布

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!

标签: r plot knitr
1条回答
Root(大扎)
2楼-- · 2019-07-18 19:11

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.

查看更多
登录 后发表回答