2015-06-15 14 views
10

Come posso utilizzare i grandi htmlwidgets (ad esempio http://rstudio.github.io/leaflet/) con reveal.js e Rmarkdown?R htmlwidgets con reveal.js

Questo MWe (non reveal.js) funziona:

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

Ma questo non lo fa:

--- 
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 riutilizzati l'esempio dal htmlwidgets-pagina web, e la rivelano .js-modello è da https://github.com/jjallaire/revealjs

risposta

4

Per utilizzare reveal.js è necessario specificare i widget di framework e di estensione nell'intestazione. Assicurati inoltre di avere la versione più recente di slidify e 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 

--- 
+0

quindi suppongo che sia necessario sostituire la linea extwidgets con qualcosa di più specifico di rCharts? – DaveRGP

+0

@DaveRGP questo esempio non funziona più? –

+0

in realtà ho trovato che il mio errore era altrove nel mio codice e che non avevo bisogno di includere quanto sopra per la funzionalità di cui avevo bisogno. Scuse. – DaveRGP