Learn R Programming

flow (version 0.0.1)

flow_debug: Debug With Flow Diagrams

Description

These functions are named after the base functions debug(), undebug() and debugonce(). flow_debug() will call flow_run(), with the same additional arguments, on all the following calls to f() until flow_undebug() is called. flow_debugonce() will only call flow_run() on the next call to f().

Usage

flow_debug(
  f,
  prefix = NULL,
  swap = TRUE,
  code = TRUE,
  ...,
  out = NULL,
  svg = FALSE,
  browse = FALSE
)

flow_debugonce( f, prefix = NULL, swap = TRUE, code = TRUE, ..., out = NULL, svg = FALSE, browse = FALSE )

flow_undebug(f)

Arguments

f

function to debug

prefix

prefix to use for special comments in our code used as block headers, must start with "#"

swap

whether to change var <- if(cond) expr into if(cond) var <- expr so the diagram displays better

code

Whether to display the code in code blocks or only the header, to be more compact, if NA, the code will be displayed only if no header is defined by special comments.

...

Additional parameters passed to build_nomnoml_code()

out

a path to save the diagram to. Special values "html", "htm", "png", "pdf", "jpg" and "jpeg" can be used to export the objec to a temp file of the relevant format and open it, if a regular path is used the format will be guessed from the extension.

svg

only for default or html outut, whether to use svg rendering, rendering is more robust without it, but it makes text selectable on output which is sometimes useful

browse

whether to debug step by step (block by block), can also be a vector of block ids, in this case browser() calls will be inserted at the start of these blocks

Details

By default, unlike debug() and debugonce(), flow_debug() and flow_debugonce() don't trigger a debugger but only draw diagrams, this is consistent with flow_run()'s defaults. To browse through the code, use the browse argument.