Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rmarkdown : embed html file to ioslides

I produce interactive plots with plotly, and save them as html pages. I'm new to ioslides and Rmarkdown, so I searched through the internet, and found no solution. I want to include a plotly graph with .html extension to my slide. So I tried:

---
title: "Advanced Physics Project"
author: "mcandar"
output: 
  ioslides_presentation:
    widescreen: true
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

## Introduction
![my graph](myfile.html)

enter image description here

and it does not work. What I want is a slide with my html graph embedded inside and its interactive features should work properly. Is it possible?

like image 817
mccandar Avatar asked Dec 20 '16 07:12

mccandar


People also ask

Can you write HTML in R markdown?

An R Markdown document is written in markdown (an easy-to-write plain text format) and contains chunks of embedded R code, like the document below. --- output: html_document --- This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents.

What is Ioslide?

ioslides is one of the presentation format that can be easily put together using R Markdown. It has good compatibility with html, and very easy set-up.

How do you add a table of contents to a RMD?

You can embed an R code chunk like this: ```{r} summary(cars) ``` You can also embed plots, for example: ```{r, echo=FALSE} plot(cars) ``` ### Header 3 Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot. I tried running this in RStudio v 0.98.


1 Answers

Option 1: Use an iframe:

---
title: "Advanced Physics Project"
author: "mcandar"
output: 
  ioslides_presentation:
    widescreen: true
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

<iframe src="myfile.html"></iframe>

Option 2: includeHTML

```{r}
shiny::includeHTML("myfile.html") 
```

enter image description here

like image 177
Martin Schmelzer Avatar answered Oct 04 '22 17:10

Martin Schmelzer