gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 11:28:58 26 4
gpt4 key购买 nike

根据documentation ,使用 R 的“传单”包创建的传单输出可以包含在 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)
```

我的目标是创建一个包含传单输出的演示文稿。如何做到这一点?

最佳答案

不是真正的解决方案,而是一种解决方法:当从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。

关于r - 如何将 Leaflet (for R)-output 包含到 RMarkdown 演示文稿中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35894401/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com