Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R htmlwidgets with reveal.js

How can I use the great htmlwidgets (for example http://rstudio.github.io/leaflet/) with reveal.js and Rmarkdown?

This mwe (not reveal.js) works:

---
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
```

But this one doesn't:

---
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
```

I re-used the example from the htmlwidgets-webpage, and the reveal.js-template is from https://github.com/jjallaire/revealjs

like image 233
Chris Avatar asked Jun 15 '15 00:06

Chris


1 Answers

To use reveal.js you need to specify the framework and extension widgets in your header. Also make sure you have the newest version of slidify and 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

--- 
like image 166
Steve Bronder Avatar answered Nov 07 '22 03:11

Steve Bronder