knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
“Flipbooks” present side-by-side, aligned, incremental code-output evolution via automated code parsing and reconstruction. Like physical flipbooks, they let the 'reader' watch a scene evolve at their own pace. Flipbooks seek to reduce the guesswork involved between code and its behavior by presenting substeps of a coding pipeline; the reader of a flipbook observes the partial code that is used to create “A.1”, “A.2”, “A.3” etc. all the way up to “B”.
Here's the 'minimal flipbook' template that's available with the package:
View flipbook in a new tab{target="_blank"}
knitr::include_graphics("https://evamaerey.github.io/flipbookr/minimal_flipbook.gif")
The create a flipbook isn't hard because parsing and reconstruction of code pipelines into substeps is automated!
flipbookr's chunk_reveal()
disassembles a single code chunk and creates the "build" of multiple partial-code chunks on different slides (the --- is automatically generated for you too).
Check out the details on how to do this in this doublecrocheted version of the same flipbook{target="_blank"} (quotes the .Rmd source on some slides).
You can install the development version of flipbookr with devtools as follows:
devtools::install_github("EvaMaeRey/flipbookr")
You will most likely use this package with the rmarkdown presentation tool, Xaringan, which is available on CRAN:
install.packages("xaringan")
The package includes several templates for building a flipbook that demonstrates various flipbooking modes.
The templates can be accessed from within RStudio. For example: New File -> RMarkdown -> From Template -> A Minimal Flipbook. The templates are:
Here's a flipbook going through some of the internal flipbookr functions.
library(tidyverse) Titanic %>% data.frame() %>% uncount(Freq) %>% ggplot() + aes(x = Sex) + geom_bar(position = "fill") + aes(fill = Survived)
chunk_reveal_live(chunk_name = "sample_chunk")
download.file(url = "https://evamaerey.github.io/flipbookr/", destfile = "myhtml.html") rstudioapi::viewer("myhtml.html")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.