Say you've got some nifty new statistical method, and you're comparing it to the prior state of the art. You want to wow them with a graph that shows the old method degrading badly on hard problems, while your new method is clearly more robust. But before they are impressed, they have to parse the graph. What is being graphed against what; which line is which; etc. Even if your audience were just one person, they'd be gradually figuring all of that out, so instead of a sharp moment of "oooh!", they'd have a more blurry and less memorable impression of your method. And of course a large audience will react even more diffusely.
What you want in this situation is an incremental graph. Start out by showing them how the old method degrades, then, only after they understand the structure of the graph, add the line for your new method. "Oooh!"
So, how do you do that in an R markdown presentation? Well, using the current version of the package, you'd have to make two separate slides, copying and pasting your graphing code. This violates the DRY (Don't Repeat Yourself) principle. And that causes problems; for instance, if you wanted to change some formatting (say, the background color of your graphs), you'd have to make the changes twice, and hope that the formatting doesn't tangle with the incremental changes.
But now, I've made a better way to do it. It's just my own fork of rmarkdown for the moment, but it's a pending pull request, so hopefully soon this will be available to everyone.
So unless you're reading this from the future, first you'll have to install my fork:
```{r}
install.packages("devtools")
library(devtools)
dev_mode(on=T)
install_github("rmarkdown","jamesonquinn")
# use my fork
# if you want to go back to the standard version, do:
# dev_mode(on=F) #and you are back to having stable ggplot2
```
Here's how you might use them to create an incremental presentation:
```{r, results='asis', error=FALSE, message=FALSE, warning=FALSE, echo=FALSE}
gginc(1:2, ggplot(diamonds, aes(clarity, fill=stages("diamonds",cut))) + geom_bar())
```
This creates a two-stage incremental graph (because of the first argument to gginc). In stage 1, fill="diamonds", so all the bars are the same solid color; in stage 2, fill=cut, so the bars change to have separate colors for each cut.
```{r, results='asis', error=FALSE, message=FALSE, warning=FALSE, echo=FALSE}
gginc(1:2, ggplot(diamonds, aes(clarity, fill=stages("diamonds",cut))) + geom_bar())
```
This creates a two-stage incremental graph (because of the first argument to gginc). In stage 1, fill="diamonds", so all the bars are the same solid color; in stage 2, fill=cut, so the bars change to have separate colors for each cut.