Slidify

Reproducible HTML Slides from R Markdown

Ramnath Vaidyanathan
Assistant Professor, McGill University

Download

Slidify is a tool that makes it easy to create, customize and publish, reproducible HTML5 slide decks using R Markdown.

Install Slidify

Slidify can be installed from github using Hadley's devtools package

library(devtools)
install_github('slidify', 'ramnathv')

If you are on Windows, you will need gcc and RTools to get devtools working.

Slidify is a tool that makes it easy to create, customize and publish, reproducible HTML5 slide decks using R Markdown.

Create Deck

You can initialize a slide deck using the author function

library(slidify)
author("mydeck")

This will do the following

  1. Create a new directory named mydeck.
  2. Copy necessary scaffolding for the presentation.
  3. If git is installed on the system
    • initialize a new git repo.
    • checkout and switch to gh-pages branch
    • add and commit all files to the repo
  4. Open index.Rmd for you to edit.

Edit Slides

 ---
 title    : Title 
 substitle: Subtitle
 author   : Author
 job      : Job
 widgets  : []
 mode     : selfcontained
 ---

 ## Slide 1

 Use an empty line followed by three dashes to separate slides!

 --- .class #id 

 ## Slide 2
  1. Edit the metadata in the YAML front matter.
  2. Write your slides in R Markdown.
  3. Separate your slides by an empty blank line followed by three dashes.

Add Slide Classes

Add slide classes and id by appending them to the slide separator

 --- #montreal bg:url(http://goo.gl/cF6W2)

 ## Montreal by Night Time

 --- #dillinger

 <iframe src = 'http://dillinger.io' height='600px'></iframe>

 --- .middle 

 Slidify is Awesome

Montreal by Night Time

Slidify is Awesome

Slidify is a tool that makes it easy to create, customize and publish, reproducible HTML5 slide decks using R Markdown.

Customize

Slidify is designed to be modular and provide a high degree of customization for the more advanced users.

Option Description
framework slide generation framework to use
theme theme to use for styling slide content
highlighter tool to use for syntax highlighting
hitheme style to use for syntax highlighting
mode draft, standalone or selfcontained
url path to assets and libraries

Style your Deck

Slide Source

---  plot #simple-plot

## A Simple Plot ##

Let us create a simple scatterplot.

```{r simple-plot, fig.height = 6, fig.align = 'center', message = F}
require(ggplot2)
qplot(wt, mpg, data = mtcars)
```

knit Slide

---  plot #simple-plot

## A Simple Plot ##

Let us create a simple scatterplot.

```r
require(ggplot2)
qplot(wt, mpg, data = mtcars)
```

![plot of chunk simple-plot](figure/simple-plot.png) 

Parsed Slide

$id
[1] "simple-plot"

$html
[1] "<h2>A Simple Plot</h2>\n\n<p>Let us create a simple scatterplot.</p>\n\n<pre><code class=\"r\">require(ggplot2)\nqplot(wt, mpg, data = mtcars)\n</code></pre>\n\n<p><img src=\"figure/simple-plot.png\" alt=\"plot of chunk simple-plot\"> </p>\n"

$header
[1] "<h2>A Simple Plot</h2>"

$level
[1] "2"

$title
[1] "A Simple Plot"

$content
[1] "<p>Let us create a simple scatterplot.</p>\n\n<pre><code class=\"r\">require(ggplot2)\nqplot(wt, mpg, data = mtcars)\n</code></pre>\n\n<p><img src=\"figure/simple-plot.png\" alt=\"plot of chunk simple-plot\"> </p>\n"

Acknowledgements

R Packages

All the heavy lifting is actually done by three awesome R packages. Slidify is merely a wrapper around them.

  • Yihui Xie (knitr)
  • RStudio (markdown)
  • Edwin de Jonge (whisker)

HTML5 Slide Frameworks

Slidify builds on HTML5 slide frameworks created by several individuals and organizations.

Framework Author License
html5slides Luke Mah, Marcin Wichary Apache
deck.js Caleb Troughton MIT/GPL
dzslides Paul Roget DWTFYW
html5rocks Google Apache
landslide Adam Zapletal Apache
shower Vadim Makeev MIT
slidy Dave Ragett MIT
slideous Stefan Goessner LGPL

Syntax Highlighters

Syntax highlighting is powered by open source highlighters.

Highlighter Author License
highlight.js Software Maniacs MIT
Google Prettify Google Apache
highlight Romain Francois GPL

Markdown-HTML5 Converters

I have extensively borrowed ideas and features from HTML5 slide converters written in other languages. I have also borrowed from blogging frameworks.

Language Framework
Ruby showoff
Ruby slideshow
Ruby keydown
Ruby ruhoh
Python hieroglyph
Python landslide
Haskell pandoc

License

slidify is made available under the MIT License. All included css and javascript are licensed under the terms specified by the respective libraries.

MIT License

Copyright (C) 2012 Ramnath Vaidyanathan

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE

References

HTML5 Slides with R

R Markdown