Gina Reynolds, February 2020
Flipbooks present code step-by-step and side-by-side with its output. The incremental code/result reveal help people digest longer manipulation and analysis pipelines as well as plot builds. Two helpful features are incrementalism and movie-like presentation.
Long pipelines of code can produce attractive outputs. But when an observer knows only initial input and final output, a pipeline can feel like a long stretch of highway that has no exit or entry ramps. Flipbook are designed to give users a lot of on and off ramps even for long pipelines; in a flipbook, the users can isolate and gain insight about short stretches along the pipeline that are useful for their particular project – all the while engaged by the creativity brought by the author in pursuit of his or her original goal. Flipbooks enable us to isolate how individual functions work in context.
The presentation of intermediate states on via slide-show presentation platform means that states can be aligned and superimposed. This way, the audience doesn’t need to engage in visual search which requires focus and concentration – but rather effortlessly observes changes via motion detection. Temporal rather than spatial offset makes it easy to notice changes to the code and the resultant changes to the output.
To get a sense of how they work, click once in the example box the below to initiate the session; then use the right and left arrow to “flip” through the book to see how to make an animated “racing” bar chart of the population size of the most populous countries over time.
For easier reference, I’ve sorted instructive flipooks into three main categories. You can link to guides to further subtopics here:
Data Wrangling Data Visualization with ggplot2 Statistical Analysis
Mostly, I’ve created these resources while preparing for my classes at the Korbel School of International Studies at the University of Denver. So many thanks due to my students for being such an amazing and motivating bunch. These repositories are my teaching materials, and are constantly being updated and revised.
Would you like to make a flipbook? We try to make that easy for you with {flipbookr}. To get started have a look at A minimal Flipbook, the template for which will be available once you install the flipbook building package {flipbookr}. The steps to building your first flipbook are as follows:
install.packages("xaringan")
remotes::install_github("EvaMaeRey/flipbookr")
Once you have completed steps 1-3, you can also follow along with the live demo that I presented at the RStudio Conference, 2020 (the demo is at 6’25") — but consider using the setup code chunk in the template — I don’t do this in the demo!
The template (step 4) will create the following book, which contains examples of flipbooking modes:
Here are a few known issues to watch for:
chakra: libs/remark-latest.min.js
We’d love to hear from you! How is your flipbook building experience? You can contribute feedback via Twitter @EvaMaeRey and via issues on Github.com/EvaMaeRey/flipbookr.
If you are interested in contributing to {flipbookr}, you might consider getting some of the intuition of the internal functions by browsing through the resource below, or link to it here:
In mid 2018 Garrick Aden-Buie, a data scientist at the Moffitt Cancer Center, created and debuted a side-by-side format for code and figure output in the slide-show tool, Xaringan, an RMarkdown tool. He demonstrated in incremental steps how someone might build up a plot using the popular R visualization package ggplot2. In August 2018, I emulated this work, but using a code style I developed which I called “slowggplot2”, which is entirely sequential and more incremental than typical workflows. This style uses one ggplot function for every plotting decision that is made (when possible); this format is ideal for automatically parsing and reconstructing partial builds of the plots; and reconstructions clearly connect the coding decision and associated behavior because differences between states is small. In September, Emi Tanaka, a Lecturer in Statistics at the University of Sydney, implemented a similar sequential workflow demonstration, which she partially automated.
I approached Garrick and Emi in October about working together on “flipbooks”. We soon had a fully automated framework to parse ggplot2 code, and present the code reconstruction along with associated output!
The procedure to automatically parse and reconstruct code was tested and refined on small projects. Then, I created a “flipbook” of a sizable collection of my portfolio of data visualizations, originally created for the initiative #MakeoverMonday. I publicized the work in February, 2019; the ggplot flipbook was met an enthusiastic reception.
Since then, there have been a number of changes to the fundamental code to improve the tool and to extend use cases. Many of the capabilities that have been added are also discussed in the template.
%>%
, ->
, %+%
, %$%
) to enable presentation beyond data visualization (initially we only used the +
)#BREAK
comment)#BREAK2
, #BREAK3
etc)You can link to some flipbooks here:
If you need a theoretical exploration of the grammar of graphics and its use with ggplot2, see a ggplot2 grammar guide.
The geom pile on is a suppliment to the ggplot grammar guide and shows you a lot of “geoms” that you can use to communicate about your data. Piling up the geoms allows you to see how plot types relate to one another.
ggplot themes takes you through logic of the ggplot2 theme adjustments.