how to include Leaflet (for R)-output into RMarkdown presentation?

Viewed 6677

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?

1 Answers
Related