# This is the recommended set up for flipbooks # you might think about setting cache to TRUE as you gain practice --- building flipbooks from scratch can be time consuming knitr::opts_chunk$set(fig.width = 6, message = FALSE, warning = FALSE, comment = "", cache = F) library(flipbookr) library(tidyverse)
--
This 'minimal flipbook' template has a couple of classic examples to get you building your first flipbooks!
--
flipbooks are code-movies. The frames of the movies are slides. Here we use the R package {xaringan} to create a remark.js slideshow.
--
Slide breaks are indicated with ---
(be careful trailing white space is not allowed)
--
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).
--
We use chunk_reveal()
it 'inline', not in a code chunk.
--
Let's start!
class: inverse, middle, center
r chunk_reveal("my_cars")
cars %>% filter(speed > 4) %>% ggplot() + aes(x = speed) + #BREAK aes(y = dist) + #BREAK geom_point( alpha = .8, color = "blue" ) + aes(size = speed) #BREAK
class: inverse, center, middle
r chunk_reveal("my_cars", break_type = "user", display_type = "output", title = "### user defined break! using #BREAK message")
class: inverse, center, middle
r chunk_reveal("my_fill", break_type = "rotate", widths = c(1,1), title = "### cycle through lines of code marked #ROTATE")
ggplot(data = cars) + aes(x = speed) + aes(y = dist) + geom_point(size = 8, shape = 21, alpha = .9, color = "snow") + aes(fill = speed) + scale_fill_viridis_c(option = "magma") + #ROTATE scale_fill_viridis_c(option = "cividis") + #ROTATE scale_fill_viridis_c(option = "plasma") #ROTATE
class: inverse, center, middle
r chunk_reveal("cars_multi", break_type = 5, title = "### see multiple realizations of code")
cars %>% sample_frac(size = 1, replace = TRUE) %>% ggplot() + aes(x = speed) + aes(y = dist) + geom_count( alpha = .7, color = "blue", size = 4 ) + geom_smooth(method = lm, se = FALSE) + coord_cartesian(xlim = range(cars$speed), ylim = range(cars$dist)) + theme(legend.position = c(.9, .2))
```{css, eval = TRUE, echo = FALSE} .remark-code{line-height: 1.5; font-size: 80%}
@media print { .has-continuation { display: block; } }
code.r.hljs.remark-code{ position: relative; overflow-x: hidden; }
code.r.hljs.remark-code:hover{ overflow-x:visible; width: 500px; border-style: solid; } ```
This minimal flipbook assumes you are online when you build and view. It is going to find the most recent remark.js info online.
xaringan/remark.js slideshows are not self contained, single file slide shows. Make sure you ship all the associated files that are created to display your flipbooks/slideshows. I like to push .html and associated files to github repository and use Github Pages to host for beyond local sharing. :-)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.