如何将Rmarkdown文件编织到嵌入绘图的html文件中? [英] How can I knit a Rmarkdown file into a html file which embeds plots?

查看:392
本文介绍了如何将Rmarkdown文件编织到嵌入绘图的html文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,在Rmd文件中,有多个地方可以生成绘图.

In a Rmd file, there are several places which generate plots, for example

```{r outliers}
influencePlot (model1)
```

通过在R会话中运行,我将该文件编织为html文件和目录./figure/下的多个图像文件

I knit the file into a html file and several image files under directory ./figure/, by running in a R session

> library(knitr)
> knit("my.Rmd")

然后在bash会话中运行

and then running in a bash session

$ pandoc my.md -f markdown -t html -s -o my.html

但是html文件没有嵌入图像文件中的图,例如:

but the html file doesn't embed the plots from the image files, for example:

<img src="figure/outliers-1.png" alt="plot of chunk outliers" />

我想知道如何使html文件嵌入图像文件中的图并变得独立吗?

I was wondering how I could make the html file embed the plots from the image files and become self contained?

在RStudio中,当我单击编织到html"按钮时,例如,将绘图图像嵌入html文件中

In RStudio, when I click "knit to html" button, it embeds the plot images in html file, for example

<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhE...

RStudio的编织到html"按钮的等效命令是什么?

What is the equivalent commands to RStudio's "knit to html" button?

谢谢.

推荐答案

RStudio的编织到html"按钮的等效命令是什么?

What is the equivalent commands to RStudio's "knit to html" button?

在YAML标头中提交输出,然后使用

Submit your output in a YAML header and then use

rmarkdown::render("Your-RMD-file.Rmd")

或参见render函数及其参数的文档.

Or see the documentation for the render function and their arguments.

这篇关于如何将Rmarkdown文件编织到嵌入绘图的html文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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