Interactive slide shows with R, Org mode , and Slidy

Greg Tucker-Kellogg, June 3, 2012


  • In 2006 Hans Rosling gave an inspiring talk at TED
  • To visualise his talk he used animated bubble charts, aka motion charts
  • In May 2012, Markus Gesmann gave a talk using slide shows generated from knitr and pandoc
  • How hard is this to do using Org mode?

Org mode makes this easy

  • Normal (non-interactive) slide shows are a snap.
  • Several options documented on the Org mode site
  • Some fine options not yet on the Org mode main site
    1. Slidy (which this uses, and which Markus used).
    2. Org-html-slideshow
  • This presentation uses org-slidy, by Dov Grobgeld

How to create Slidy slides with Org

  • Copy the .js and .css files and the file to where your own source file will reside
  • put the following in your org file
    #+BIND: org-export-html-preamble nil
  • Export your org file as HTML and watch your slide show

So how do you run R from Org mode?

  • Org mode can interact with source code in >30 languages, including R.
  • typically, these are enclosed in #+BEGIN_SRC R and #+END_SRC R blocks like so
#+BEGIN_SRC R :results value raw :exports results :colnames yes
x <- c(1:10);
y <- x^2;

If you want a plot, it is just as easy

x <- c(1:10);
y <- x^2;


A googleVis line plot with some interactive features

Plot countries by credit rating

This is very slightly modified from Markus's blog post

You can also do motion charts

A note about motion charts

  • Google's motion charts use Flash, and so cannot be loaded and displayed in a file:// style URL.
  • This motion chart is in a separate file on Dropbox, and referenced by an http:// style link.
  • Org mode makes this trivially easy to do for different code blocks
    • Beginning a block with the following will embed the HTML output of R execution into a file foo.html
#+BEGIN_SRC R :results output html :file foo.html
  • If you are using Dropbox, you can embed the link in an <iframe>, which is what I do here.

A note about security

  • Letting emacs run arbitrary programs for you is potentially risky.
  • You need to tell emacs that it should be able to run R. Here's what's in my .emacs file.
 '((R . t)
   (ruby . t)
   (python . t)
   (sh . t) 
   (perl . t)
   (latex . t)))

If you are using the source of this presentation, you can type Control-C Control-C when your cursor is anywhere in the block above, and it will execute the code and set the variables to allow you to run code blocks in all of the listed languages

Thanks to …

  • Google for making the Chart Tools available