How Will an Animated GIF Work in a Textbook?

Yihui Xie 2018-07-17

When I gave my first public talk on bookdown in Chicago in 2016, I mentioned a few motivations behind this project. One of them was that I believed books should/could have richer content. I meant there could be videos, dynamic or interactive content in a book. For example, readers could be able to fit a model right inside the book if you embed a Shiny app.

Yesterday (i.e. two years later) I finally saw a real example from a tweet by Matt Crump, where he showed an animated GIF that demonstrates how small sample sizes could fool you when you look for a correlation between two variables.

how correlation behaves when there is no correlation

Nick Brown asked in a reply “How will an animated GIF work in a textbook?” I was excited to learn that Matt was working on a book written with bookdown, so the answer was “Read the web version of the book.” You can find the GIF in their text book “Answering Questions with Data”. That is exactly the type of books I was looking forward to.

BTW, actually I used a similar idea in the function animation::sim.qqnorm() to show that even when the actual distribution is Normal, the points in the QQ plot do not necessarily line up nicely on the diagonal. When the sample size is small, the uncertainty could be so big to fool you into believing that you have discovered patterns which are essentially artifacts.

Simulated QQ plots

I should also mention the VIT project (Visual Inference Tools) started by Chris Wild, in which you can find more interesting examples related to this topic.

Oh, I should also mention one of Colin Fay’s favorite tech-related memes:

a bookdown meme