According to the documentation, Leaflet output created with the "leaflet" package for R can be included into RMarkdown.
This works when the RMarkdown output is html:
---
title: "Rmarkdown HTML including Leaflet"
output: html_document
---
Show "Leaflet for R" within html: works.
```{r}
library(leaflet)
leaflet() %>%
addTiles %>% # Add default OpenStreetMap map tiles
setView(lng = 5.0, lat = 51.0, zoom = 6)
```
But fails when the RMarkdown output is a presentation:
---
title: "Rmarkdown Presentation including Leaflet"
output:
revealjs::revealjs_presentation
---
Show "Leaflet for R" within Rmarkdown presentation: fails.
```{r}
library(leaflet)
leaflet() %>%
addTiles %>% # Add default OpenStreetMap map tiles
setView(lng = 5.0, lat = 51.0, zoom = 6)
```
My objective is to create a presentation that includes the Leaflet output. How to accomplish this?
Not a real solution, but a workaround: when changing from a revealjs presentation type to ioslides, the Leaflet output is shown in the presentation. The layout and interactivity do not work flawless though.
---
title: "Rmarkdown Presentation including Leaflet"
author: "UVH"
date: "March 14, 2016"
output:
ioslides_presentation
---
Show "Leaflet for R" within Rmarkdown "ioslides" presentation: works, but not flawless.
```{r echo=FALSE}
library(leaflet)
leaflet() %>%
addTiles %>% # Add default OpenStreetMap map tiles
setView(lng = 5.0, lat = 51.0, zoom = 6)
```
As I prefer using revealjs over ioslides, I hope someone can provide a better solution that does work with revealjs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With