Package 'flipbookr'

Title: Parses Code, Creates Partial Code Builds, Delivers Code Movie
Description: Flipbooks present code step-by-step and side-by-side with its output. Flipbookr helps creators build flipbooks efficiently because code pipelines are automatically parsed and prepped for presentation as flipbooks.
Authors: Evangeline Reynolds, Garrick Aden-Buie, Emi Tanaka
Maintainer: The package maintainer <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2024-11-10 05:00:38 UTC
Source: https://github.com/evamaerey/flipbookr

Help Index


Function takes code from referenced code chunk and returns partial code sequence to series of code chunks separated by slide breaks. Upon compiling you get step-by-step code walk-through.

Description

Function takes code from referenced code chunk and returns partial code sequence to series of code chunks separated by slide breaks. Upon compiling you get step-by-step code walk-through.

Usage

chunk_reveal(chunk_name = NULL, break_type = "auto", left_assign = F,
  left_assign_add = NULL, lang = "r", omit = "#OMIT",
  code_seq = NULL, code_seq_lag = NULL, code_seq_lag2 = NULL,
  code_seq_target = NULL, code_seq_start = NULL, func_seq = NULL,
  num_breaks = NULL, display_type = c("code", "output"), title = "",
  md = NULL, md2 = NULL, replacements = NULL, replace = NULL,
  replacements2 = replacements, replace2 = replace,
  replacements3 = replacements, replace3 = replace, widths = NULL,
  float = "left", chunk_options = "", color = c("black", "black",
  "black"), font_size_code = "80%")

Arguments

chunk_name

a character string referring to the name of the source chunk for the flipbooking

break_type

"auto" is default finding appropriate breakpoints, "user" can be used with the special comment message #BREAK within the source code chunk, "non_seq" can be used for non sequential display of code with special comment messages #BREAK2 (will show in second frame) and #BREAK3 (will show in third frame), an integer input can be given too, to simply display the source code chunk multiple times which is appropriate for observing multiple realizations of sampling, "rotate" allows cycling through different lines of code, the comment #ROTATE is used for lines to by cycled through

left_assign

a logical, default is FALSE, if TRUE will print the object created in the upper left hand corner of the source code chunk at the end of each partial reveal

left_assign_add

a character string containing function for table formatting in output, for left assign case only

lang

a character string indicating what programming language will be used. "r" is default; "python" is experimental

omit

a character string, as a comment, indicating lines that should be omitted, defaults to "#OMIT"

code_seq

a list of code as character strings, the list will automatically be created based on the previous three arguments or the user can input code manually

code_seq_lag

a list of code as character strings, lagged, the list will automatically be created based on the previous three arguments or the user can input code manually

code_seq_lag2

a list of code as character strings, twice lagged, the list will automatically be created based on the previous three arguments or the user can input code manually

code_seq_target

a list of code as character strings, the length of code_seq, but only containing the last element of code_seq

code_seq_start

a list of code as character strings, the length of code_seq, but only containing the first element of code_seq

func_seq

a character string with function names; default is NULL and will reflect whatever function is highlighted from the code sequence

num_breaks

an integer, automatically calculated based on the length of the the code_seq list

display_type

a character string vector, the default is c("code", "output") for code and output to be displayed side-by-side, "output" will create spawned code chunks to only display output, "code" will create spawned code chunks only to show the partial code builds; "func" and "md" may also be displayed

title

a character string that may contain a title for the frames of the flipbook; this may included header info "## My Title" for example is a second level markdown title in Xaringan

md

a character string vector that contains markdown; each element will be shown on a separate slide in the display panel "md" (see display_type)

md2

a character string vector that contains markdown; each element will be shown on a separate slide in the display panel "md" (see display_type)

replacements

a character string vector to be replace the string indicated by the 'replace' parameter

replace

a character string to be replaced in the input code sequentially with the replacement vector elements

replacements2

a character string vector to be replace the string indicated by the 'replace2' parameter

replace2

a character string to be replaced in the input code sequentially with the replacement2 vector elements

replacements3

a character string vector to be replace the string indicated by the 'replace3' parameter

replace3

a character string to be replaced in the input code sequentially with the replacement3 vector elements

widths

a numeric vector containing relative widths for panels

float

defines css float parameter, defaults to "left"

chunk_options

input 'knitr' code chunk options as a string, default to empty string "", useful input might be "fig.height = 4, fig.width = 3"

color

defines css parameter, defaults to "black"

font_size_code

this ain't working yet!

Value

a string object is returned will only work in 'knitr' context


embed_flipbook

Description

embed_flipbook

Usage

embed_flipbook(chunk_name, break_type = "auto",
  code_file_name = paste0("embedded_flipbooks/", chunk_name, ".R"),
  rmd_path = paste0("embedded_flipbooks/", chunk_name, "_embed.Rmd"),
  title = stringr::str_replace_all(chunk_name, "_|\\.", " "),
  subtitle = "", author = "", url = paste0("embedded_flipbooks/",
  chunk_name, "_embed.html"), height = 325, font_size = 120,
  title_page = F, ...)

Arguments

chunk_name

a character string referring named chunk containing code to 'flipbook'

break_type

"auto" is default finding appropriate breakpoints, "user" can be used with the special comment message #BREAK within the source code chunk, "non_seq" can be used for non sequential display of code with special comment messages #BREAK2 (will show in second frame) and #BREAK3 (will show in third frame), an integer input can be given too, to simply display the source code chunk multiple times which is appropriate for observing multiple realizations of sampling, "rotate" allows cycling through different lines of code, the comment #ROTATE is used for lines to by cycled through

code_file_name

a .R file path where chunk's code will be saved

rmd_path

an .Rmd path were source of mini flipbook will be saved

title

a character string if a title is desired for the embedded flipbook, defaults to modified chunk name

subtitle

a character string for the embedded flipbook's subtitle, defaults to ""

author

a character string for the embedded flipbook's author info, defaults to ""

url

path to .html rendered mini flipbook

height

numeric size of iframe, defaults to 325

font_size

numeric to adjust the size of code in embedded flipbooks

title_page

logical indicating whether to include a title page for the mini flipbook, defaults to FALSE

...

inherits from chunk_reveal()


Function takes character string, splits it based on delimiter, and returns each element of the resultant vector on its own slide

Description

Function takes character string, splits it based on delimiter, and returns each element of the resultant vector on its own slide

Usage

text_reveal(text, sep = "   ", md_prefix = "#", sep_replace = "",
  slide_break = "---", class = "class: inverse, middle, center")

Arguments

text

a character string to be split and delivered piece-wise to a slide

sep

a character string to delimit the split of the input text

md_prefix

a character string prefix to each markdown element, defaults to "#"

sep_replace

a character string that will replace the delimiter, defaults to empty string ""

slide_break

a character string containing slide break characters, defaults to "—" for xaringan slideshows

class

a character string in which you can set the class, defaults to "class: inverse, middle, center"

Value

knit text to be interpreted as slides

Examples

text_reveal("Hello world", sep = " ")