class: inverse

From source .Rmd:

```r cat('--- title: "A minimal flipbook"\nsubtitle: "With flipbookr and xaringan"\nauthor: "You!"\noutput:\n xaringan::moon_reader:\n lib_dir: libs\n css: [default, hygge, ninjutsu]\n nature:\n ratio: 16:9\n highlightStyle: github\n highlightLines: true\n countIncrementalSlides: false')

---
class: inverse

###From source .Rmd:

 ```r
cat('---
\n\n```r\n# This is the recommended set up for flipbooks\n# you might think about setting cache to TRUE as you gain practice --- building flipbooks from scratch can be time consuming\nknitr::opts_chunk$set(fig.width = 6, message = FALSE, warning = FALSE, comment = "", cache = F)\nlibrary(flipbookr)\nlibrary(tidyverse)\n```\n\n\n\n# Hi!\n\n--\n\nThis \'minimal flipbook\' template has a couple of classic examples to get you building your first flipbooks!\n\n--\n\nflipbooks are code-movies.  The frames of the movies are slides. Here we use the R package {xaringan} to create a remark.js slideshow. \n\n--\n\nSlide breaks are indicated with `---` (be careful trailing white space is not allowed)\n\n--\n\nflipbookr\'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).  \n\n--\n\nWe use `chunk_reveal()` it \'inline\', not in a code chunk. \n\n--\n\nLet\'s start!\n\n\n')

# 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

From source .Rmd:

```r cat('--- class: inverse, middle, center\n\n\n# First up: classic flipbook, using defaults to walk through code pipeline\n\n\n\n\n\n')

---
class: inverse, middle, center


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





<!-- get a flipbook version of the my_cars code chunk - pauses are where parentheses are balanced -->


---
class: inverse

###From source .Rmd:

 ```r
cat('---
\n`r chunk_reveal("my_cars")`\n\n```r\ncars %>%\n  filter(speed > 4) %>%\n  ggplot() +\n  aes(x = speed) + #BREAK\n  aes(y = dist) + #BREAK\n  geom_point(\n    alpha = .8, \n    color = "blue" \n    ) + \n  aes(size = speed) #BREAK\n```\n')

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

From source .Rmd:

```r cat('--- class: inverse, center, middle\n\n\n# Next up: refer to same chunk, but use user defined breakpoints, and display output only\n\n\n\n\n\n\n')

---
class: inverse, center, middle


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






<!-- get another flipbook version of the my_cars code chunk, this time at the defined breaks and only showing output -->


---
class: inverse

###From source .Rmd:

 ```r
cat('---
\n`r chunk_reveal("my_cars", break_type = "user", display_type = "output", title = "### user defined break! using #BREAK message")`\n\n\n')

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


class: inverse

From source .Rmd:

```r cat('--- class: inverse, center, middle\n\n# Next up: cycle through different lines of code\n\n\n\n\n\n')

---
class: inverse, center, middle

# Next up:  cycle through different lines of code





<!-- get flipbook that rotates through lines, my_fill -->


---
class: inverse

###From source .Rmd:

 ```r
cat('---
\n`r chunk_reveal("my_fill", break_type = "rotate", widths = c(1,1), title = "### cycle through lines of code marked #ROTATE")`\n\n```r\nggplot(data = cars) +\n  aes(x = speed) +\n  aes(y = dist) +\n  geom_point(size = 8,\n             shape = 21,\n             alpha = .9,\n             color = "snow") +\n  aes(fill = speed) +\n  scale_fill_viridis_c(option = "magma") + #ROTATE\n  scale_fill_viridis_c(option = "cividis") + #ROTATE\n  scale_fill_viridis_c(option = "plasma") #ROTATE\n```\n\n')

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

From source .Rmd:

```r cat('--- class: inverse, center, middle\n\n# Next up: look at multiple realizations of same code\n\n\n\n\n\n')

---
class: inverse, center, middle

# Next up:  look at multiple realizations of same code





<!-- get flipbook that shows multiple realizations of the same code -->


---
class: inverse

###From source .Rmd:

 ```r
cat('---
\n`r chunk_reveal("cars_multi", break_type = 5, title = "### see multiple realizations of code")`\n\n```r\ncars %>% \n  sample_frac(size = 1, replace = TRUE) %>%      \n  ggplot() +              \n  aes(x = speed) +\n  aes(y = dist) +\n  geom_count(\n    alpha = .7,\n    color = "blue",\n    size = 4\n    ) + \n  geom_smooth(method = lm, se = FALSE) +\n  coord_cartesian(xlim = range(cars$speed),\n                  ylim = range(cars$dist)) +\n  theme(legend.position = c(.9, .2))\n```\n\n\n\n\n\n<!-- adjust font size in this css code chunk, currently 80 -->\n\n```{css, eval = TRUE, echo = FALSE}\n.remark-code{line-height: 1.5; font-size: 80%}\n\n@media print {\n  .has-continuation {\n    display: block;\n  }\n}\n\ncode.r.hljs.remark-code{\n  position: relative;\n  overflow-x: hidden;\n}\n\n\ncode.r.hljs.remark-code:hover{\n  overflow-x:visible;\n  width: 500px;\n  border-style: solid;\n}\n```\n\n\n')

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

---
class: inverse

###From source .Rmd:

 ```r
cat('---
\n# Notes: \n\n- This minimal flipbook assumes you are online when you build and view.  It is going to find the most recent remark.js info online.\n\n- 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. :-)\n')

Notes:



EvaMaeRey/flipbookr documentation built on Nov. 19, 2023, 1:46 p.m.