使用块头保存图 [英] Using header of chunk to save plot

查看:57
本文介绍了使用块头保存图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我一直在寻找答案,但还没有真正找到任何东西.我希望董事会中没有像这样的东西,所以我不会浪费任何时间.在我假设RStudio的最新升级中,我用来保存绘图的方法消失了.以下是其外观的示例块:

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)
```

执行此操作后,代码仍将编译.但是,当我编织代码以保存图表时,它不会保存图表.是否有与更新的RStudio/knitr兼容的类似方法?感谢您的帮助!

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!

推荐答案

,您可以在Rmd顶部的html_document输出优先事项部分中添加self_contained:no选项.但是图像嵌入在html中,因此您实际上并不需要图像文件夹– rawr

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

像这样:

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

res of knitr document...

这将生成几个新目录,在"figure-html"目录中,您可以找到图像.

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

这篇关于使用块头保存图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆