根据documentation,使用R的“leaflet”包创建的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输出的演示文稿。如何做到这一点?
答案 0 :(得分:1)
不是一个真正的解决方案,而是一种解决方法:当从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一起使用。