如何将大的htmlwidget(例如http://rstudio.github.io/leaflet/)与reveal.js和Rmarkdown一起使用?
这个mwe(不是Reveal.js)可以工作:
---
title: "Maptest 1"
output: html_document
---
## Map
```{r, echo=FALSE}
library(leaflet)
m <- leaflet()
m <- addTiles(m)
m <- addMarkers(m, lng=174.768, lat=-36.852, popup="The birthplace of R")
m
```
但这不是:
---
title: "Maptest 2"
output: revealjs::revealjs_presentation
---
## Map
```{r, echo=FALSE}
library(leaflet)
m <- leaflet()
m <- addTiles(m)
m <- addMarkers(m, lng=174.768, lat=-36.852, popup="The birthplace of R")
m
```
我重新使用了htmlwidgets-webpage上的示例,reveal.js-template来自https://github.com/jjallaire/revealjs。
最佳答案
要使用reveal.js,您需要在 header 中指定框架和扩展小部件。另外,请确保您拥有slidify和htmlwidgets的最新版本。
---
title : Titley Title Titler
subtitle : subtitileir
author : Author Authoria
job : Jobby job, CJJ
framework : revealjs # {io2012, html5slides, shower, dzslides, ...}
highlighter : highlight.js # {highlight.js, prettify, highlight}
hitheme : github #
widgets : [] # {mathjax, quiz, bootstrap}
mode : selfcontained # {standalone, draft}
knit : slidify::knit2slides
ext_widgets: {rCharts: "libraries/highcharts"}
revealjs:
theme: Simple
---
### Title-y Title Titler
Tu-title space title
\- Author Authorio
---
关于具有reveal.js的R htmlwidgets,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30835973/