1

For example, on this webpage there are two htmlwidgets (a leaflet and a DataTable).

I would like to create a local R Markdown HTML document that embeds one of these htmlwidgets by directly linking to them, like when you embed a YouTube video via an iframe.

Any idea?

What I've tried so far is

---
title: "Test Embedded"
output:
  html_document:
    css: styles.css
---

<!-- http://stackoverflow.com/questions/11122249/scale-iframe-css-width-100-like-an-image -->
<div class="h_iframe">
<!-- a transparent image is preferable -->
<p><img class="ratio" src="http://placehold.it/16x12"/> <iframe src="https://r-in-grenoble.github.io/members.html#htmlwidget-21bab010f9ed250fc856" style="border: 0" frameborder="0" scrolling="no"></iframe></p>
</div>

where styles.css contains

html,body        {height:100%;}
.wrapper         {width:100%;height:100%;margin:0 auto;background:#CCC}
.h_iframe        {position:relative;}
.h_iframe .ratio {display:block;width:100%;height:auto;}
.h_iframe iframe {position:absolute;top:0;left:0;width:100%; height:100%;}

Yet, it seems to embed the whole webpage, not only the corresponding htmlwidget.

F. Privé
  • 11,423
  • 2
  • 27
  • 78
  • Did you try using a `html` codechunck? [See also here for possible language engines](http://rmarkdown.rstudio.com/authoring_knitr_engines.html). HTML isn't mentioned, but as bot CSS and JS are available, I would be surprised if HTML isn't. – Jaap Sep 25 '17 at 09:15
  • @Jaap You can use HTML code directly in a markdown document. I don't think this is the problem here. – F. Privé Sep 25 '17 at 09:28

0 Answers0