Pages

29 May 2012

knitr, Slideshows, and Dropbox

I just noticed that Markus Gesmann has a nice post on using RStudio, knitr, Pandoc, and Slidy to create slideshows. After my recent attempt to use deck.rb to turn a Markdown/knitr file into a deck.js presentation I caved in and also decided to go with Pandoc and Slidy.

For me, Slidy produced the cleanest slides of the three formats that Pandoc supports. The presentation is here and the source is here.

The only thing I really disliked was having to use <br /> or something similar to keep the text from bunching up at the top of the slides, which looked strange when projected onto a screen. You can customise Slidy CSS files, but I haven’t got around to that yet.

In this post I don’t want to duplicate what Markus Gesmann has already done. Instead, I wanted to mention two things that I noticed/thought about while making my presentation:

The new MathJax syntax implemented in RStudio 0.96.227 doesn’t seem to work with Pandoc. It just renders latex as if it was part of the equation rather than the qualifier to the equation begin delimiter. To get around this I just used the regular old $ $ and $$ $$ syntax.

It’s pretty easy to host presentations with Dropbox. Just make sure all of your files are in the same folder in your Public folder. If you want output from knitr to go into and be retrieved from someplace else, you can use the desired base URL for these files by adding this code after the Pandoc title information:

```{r setup, echo=FALSE}
opts_knit$set(base.url = "")
```

Where base.url = "" includes the URL of the folder you want the output stored in.

All items in a folder in Dropbox’s Public folder have the same base URL.

I learned about base.url from Yihui Xie’s source code for his knitr/Markdown example on github. He uses it to save and retrieve figures from other folders on github.

Extra: Pandoc Code

I used the following Pandoc code in the Terminal to convert the .md file to Slidy:

I figured out that it works in RStudio if you use 2 tabs instead of 1 to indent the nested bullet. One thing I don't understand is that the indented bullet is italicized and I can't find an easy way to un-italicize it. Do you have any idea if this is a feature or a bug or how to change it?