Ude*_* VH 6 r leaflet r-markdown
根据文档,使用 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)
```
Run Code Online (Sandbox Code Playgroud)
但是当 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)
```
Run Code Online (Sandbox Code Playgroud)
我的目标是创建一个包含传单输出的演示文稿。如何做到这一点?
这不是一个真正的解决方案,而是一个解决方法:从 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)
```
Run Code Online (Sandbox Code Playgroud)
由于我更喜欢使用 Revealjs 而不是 ioslides,因此我希望有人能够提供一个可以与 Revealjs 配合使用的更好的解决方案。