micro-flipbooks

How to make embeddable micro-flipbooks (single topic example) for embedding in bookdown HTML in e-books

Peter Higgins https://higgi13425.github.io/medical_r/
10-14-2020

How to make an embeddable micro-flipbook

Start with picking a topic or function you want to teach.

Draft, on paper, a rough outline of the topic and the examples you want to show, building in complexity.

Open the mini-flipbooks project in RStudio. You can fork this from https://github.com/higgi13425/mini_flipbooks if you would like.

New File

Open a new file - File/New/Rmarkdown/From Template/Ninja Themed Presentation

(Note: it is often easiest to open a working example, like across_microflip_1 - this will include YAML edits, setup packages, etc., and Save As.. to the name of your new micro-flipbook)

Name it

Then give it a name, like
function-name_microflip_#_topic.Rmd (increment # for each additional example)

Delete Lots of Stuff

Then delete everything from line 30 - line 576 if you are using the Ninja template.

Edit the YAML

Update

Edit the Setup chunk

Edit opts_chunk$set to include

and delete options(htmltools.dir.version = FALSE)

Then Add

Edit the xaringan-themer chunk

For a consistent style, I use:

xaringanthemer::style_duo_accent(
  primary_color = "#00274C",
  secondary_color = "#FFCB05",
  header_font_google = google_font("Lato"),
  text_font_google   = google_font("Manrope"),
  code_font_google   = google_font("Roboto Mono"),
  base_font_size = "20px",
   code_font_size = "2rem",
)   


You can copy and paste this style, or
you can make your own version.

Start adding headers to preparatory slide

3 hashtags - title line on slide
4 hashtags - subhead text
Also add body text to explain what you are going to be showing.

Show the syntax and arguments

then add a divider to start a new slide with 3 horizontal dashes on a single line.
This next slide will be your flipbook slide

Add your named chunk of R code

# start with data
prostate %>%
# apply t_test from infer
# with correct arguments
  t_test(TVol ~ AA, 
         order = c("0", "1"))
# Interpreting the output:
# The t statistic is first
# followed by degrees of freedom
# then the p value
# the default alternative: two.sided
# then the confidence bounds
# output is a tibble so that it is 
# easy to use these results


Note that explanatory material is put in comments with a hashtag - can be in-between code lines, or at the end

Then reveal your code line by line with inline r code using the chunk_reveal function:

chunk_reveal("ttest1", 
    break_type = "auto", 
    title = "Tidy version from the {infer} package")`


Note that this references the name of the chunk above,
sets the break_type to “auto” (there are lots of other options), and
gives the microflipbook slide itself a title.

Then (if you want more explanatory material) insert a new slide by adding 3 dashes alone on a single line

Add the explanatory text with Rmd formatting.

Prettifying with CSS

Then (if desired) add a css chunk (example below) to adjust your code font - can adjust line height or font size.

This css chunk does not have to be on a separate slide

.remark-code{line-height: 1.5; font-size: 80%}

Ending Clearly

To clarify that your student has reached the end of the flipbook, you can add a comment line, like ### THE END

or even a divider line

With 3 dashes ---

to create a new slide with #THE END

Citation

For attribution, please cite this work as

Higgins (2020, Oct. 14). Medical R: micro-flipbooks. Retrieved from https://higgi13425.github.io/medical_r/posts/2020-10-14-micro-flipbooks/

BibTeX citation

@misc{higgins2020micro-flipbooks,
  author = {Higgins, Peter},
  title = {Medical R: micro-flipbooks},
  url = {https://higgi13425.github.io/medical_r/posts/2020-10-14-micro-flipbooks/},
  year = {2020}
}