如何将Leaflet(for R)-output包含在RMarkdown演示文稿中?

根据
documentation,使用R的“传单”包创建的Leaflet输出可以包含在RMarkdown中.

当RMarkdown输出为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)
```

但是当RMarkdown输出是演示文稿时失败:

---
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)
```

我的目标是创建一个包含Leaflet输出的演示文稿.怎么做到这一点?

最佳答案 这不是一个真正的解决方案,而是一种解决方法:当从revealjs表示类型更改为ioslides时,Leaflet输出将显示在演示文稿中.然而,布局和交互性并不完美.

---
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)
```

由于我更喜欢​​使用revealjs而不是ioslides,我希望有人可以提供一个更好的解决方案,与revealjs一起使用.

点赞