title: Include HTML files in R Markdown file?
body: <h1>Quick Summary</h1>
  
  <p>How do I place HTML files <strong><em>in place</em></strong> within an R Markdown file?</p>
  
  <h1>Details</h1>
  
  <p>I have created some nice animated choropleth maps via <a href="https://cran.r-project.org/web/packages/choroplethr/vignettes/g-animated-choropleths.html" rel="noreferrer">choroplethr</a>.</p>
  
  <p>As the link demonstrates, the animated choropleths function via creating a set of PNG images, which are then rolled into an HTML file that cycles through the images, to show the animation.  Works great, looks great.</p>
  
  <p>But now I want to embed / incorporate these pages within the .Rmd file, so that I have a holistic report including these animated choropleths, along with other work.</p>
  
  <p>It seems to me there should be an easy way to do an equivalent to</p>
  
  <p>Links:</p>
  
  <pre><code>[please click here](http://this.is.where.you.will.go.html)
  </code></pre>
  
  <p>or</p>
  
  <p>Images:</p>
  
  <pre><code>![cute cat image](http://because.that.is.what.we.need...another.cat.image.html)
  </code></pre>
  
  <p>The images path is precisely what I want:  a reference that is "blown up" to put the information in place, instead of just as a link.  How can I do this with a full HTML file instead of just an image?  Is there any way?</p>
  
  <h1>Explanation via Example</h1>
  
  <p>Let's say my choropleth HTML file lives in my local path at <code>'./animations/demographics.html'</code>, and I have an R Markdown file like:</p>
  
  <pre><code>---
  title: 'Looking at the demographics issue'
  author: "Mike"
  date: "April 9th, 2016"
  output:
    html_document:
      number_sections: no
      toc: yes
      toc_depth: 2
  fontsize: 12pt
  ---
  
  # Introduction
  
  Here is some interesting stuff that I want to talk about.  But first, let's review those earlier demographic maps we'd seen.
  
  !![demographics map]('./animations/demographics.html')
  </code></pre>
  
  <p>where I have assumed / pretended that <code>!!</code> is the antecedent that will do precisely what I want:  allow me to embed that HTML file in-line with the rest of the report.</p>
  
  <h1>Updates</h1>
  
  <p>Two updates.  Most recently, I still could not get things to work, so I pushed it all up to a <a href="https://github.com/lazarillo/persuasive_analytical_report/tree/master" rel="noreferrer">GitHub repository</a>, in case anyone is willing to help me sort out the problem.  Further details can be found at that repo's Readme file.</p>
  
  <p>It seems that being able to embed HTML into an R Markdown file would be incredibly useful, so I keep trying to sort it out.</p>
  
  <hr>
  
  <p>(Older comments)</p>
  
  <p>As per some of the helpful suggestions, I tried and failed the following in the R Markdown file:</p>
  
  <p>Shiny method:</p>
  
  <pre><code>```{r showChoro1}
  shiny::includeHTML("./animations/demographics.html")
  ```
  </code></pre>
  
  <p>(I also added <code>runtime:Shiny</code> up in the YAML portion.)</p>
  
  <p><code>htmltools</code> method:</p>
  
  <pre><code>```{r showChoro1}
  htmltools::includeHTML("./animations/demographics.html")
  ```
  </code></pre>
  
  <p>(In this case, I made no changes to the YAML.)</p>
  
  <p>In the former case (<code>Shiny</code>), it did not work at all.  In fact, including the HTML seemed to muck up the functionality of the document altogether, such that the runtime seemed perpetually not-fully-functional.  (In short, while it appeared to load everything, the "loading" spindel never went away.)</p>
  
  <p>In the latter case, nothing else got messed up, but it was a broken image.  Strangely, there was a "choropleth player" ribbon at the top of the document which would work, it's just that none of the images would pop up.</p>
  
  <hr>
  
  <p>For my own sanity, I also provided simple links, which worked fine.</p>
  
  <pre><code>[This link](./animations/demographics.html) worked without a problem, except that it is not embedded, as I would prefer.
  </code></pre>
  
  <p>So it is clearly a challenge with the embedding.</p>