How To Embed External Html In R Distill Rmd
Question: How do I place HTML files in place within an R Distill Markdown file? Background: I would like to embed / incorporate an external html file within a Distill Rmd file. I d
Solution 1:
You might want to double check your R chunk arguments, does it have include=FALSE
? because then you would be calling the HTML file, but then telling it not to be included, here is my distill Rmd file and the output with the included HTML code.
Rmarkdown
---title:"Untitled"output:distill::distill_article---
```{rsetup}knitr::opts_chunk$set(echo=FALSE)library(htmltools)htmltools::includeHTML("test2.html")```
HTML: titled test2.html
located in same directory as .Rmd
<html><head></style><title>Title</title></head><body><p>This is an R HTML document. When you click the <b>Knit HTML</b> button a web page will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:</p><divclass="chunk"id="unnamed-chunk-1"><divclass="rcode"><divclass="source"><preclass="knitr r" ><spanclass="hl kwd">summary</span><spanclass="hl std">(cars)</span></pre></div><divclass="output"><preclass="knitr r">## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
</pre></div></div></div><p>You can also embed plots, for example:</p><divclass="chunk"id="unnamed-chunk-2"><divclass="rcode"><divclass="source"><preclass="knitr r" ><spanclass="hl kwd">plot</span><spanclass="hl std">(cars)</span></pre></div></div><divclass="rimage default"><imgsrc="figure/unnamed-chunk-2-1.png"title="plot of chunk unnamed-chunk-2"alt="plot of chunk unnamed-chunk-2"class="plot" /></div></div></body></html>
output rendered to html
Post a Comment for "How To Embed External Html In R Distill Rmd"