带有reveal.js的R htmlwidgets

Chr*_*ris 10 r knitr r-markdown reveal.js

如何在reveal.js和Rmarkdown中使用优秀的htmlwidgets(例如http://rstudio.github.io/leaflet/)?

这个mwe(不是rev​​eal.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
```
Run Code Online (Sandbox Code Playgroud)

但是这个没有:

---
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
```
Run Code Online (Sandbox Code Playgroud)

我重新使用了htmlwidgets-webpage中的示例,reveal.js-template来自https://github.com/jjallaire/revealjs

Ste*_*rin 3

要使用 Reveal.js,您需要在标头中指定框架和扩展小部件。还要确保您拥有最新版本的 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

--- 
Run Code Online (Sandbox Code Playgroud)