A minimal flipbook

# 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)

Hi!

--

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

First up: classic flipbook, using defaults to walk through code pipeline


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

Next up: refer to same chunk, but use user defined breakpoints, and display output only


r chunk_reveal("my_cars", break_type = "user", display_type = "output", title = "### user defined break! using #BREAK message")


class: inverse, center, middle

Next up: cycle through different lines of code


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

Next up: look at multiple realizations of same code


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; } ```


Notes:



Try the flipbookr package in your browser

Any scripts or data that you put into this service are public.

flipbookr documentation built on May 31, 2021, 5:10 p.m.