How can I knit a Rmarkdown file into a html file which embeds plots?

一曲冷凌霜 提交于 2020-04-30 09:21:07

问题


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

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

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

and then running in a bash session

$ pandoc my.md -f markdown -t html -s -o my.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" />

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

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...

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

Thanks.


回答1:


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

Submit your output in a YAML header and then use

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

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



来源:https://stackoverflow.com/questions/61315190/how-can-i-knit-a-rmarkdown-file-into-a-html-file-which-embeds-plots

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