问题
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