Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using header of chunk to save plot

Tags:

plot

r

knitr

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!

like image 771
user2221184 Avatar asked Jun 10 '26 02:06

user2221184


1 Answers

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.

like image 173
user2221184 Avatar answered Jun 11 '26 17:06

user2221184



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!