boom {boomer}R Documentation

Print the Output of Intermediate Steps of a Call

Description

Usage

boom(expr, clock = NULL, print = NULL)

rig(fun, clock = NULL, print = NULL)

rigger(clock = NULL, print = NULL)

rig_in_namespace(..., clock = NULL, print = NULL)

Arguments

expr

call to explode

clock

whether to time intermediate steps. Defaults to getOption("boomer.clock") evaluated at run time (FALSE unless you change it). The execution time of a step doesn't include the execution time of its previously printed sub-steps.

print

A function, a formula or a list of functions or formulas, used to modify the way the output is printed. Defaults to getOption("boomer.print") evaluated at run time (base::print unless you change it)'.

fun

function ro rig()

...

Functions to rig in their namespace

If the print argument is a function, it will be used to print, or to transform the output before it's printed. Use invisible to display nothing, useful possibilities are str or dplyr::glimpse.

rlang's formula notation is supported, so for instance you can type: print = ~ dplyr::glimpse(., width = 50).

Sometimes you might want to print a specific type of object in a custom way, in this case you can provide a named list, if you provide an unnamed element it will be used as the default, and named elements will define how objects of the given S3 class are printed. For instance print = list(str, data.frame = tibble::as_tibble)

Value

boom() returns the output of the call. rig() returns the modified input function. rig_in_namespace() returns invisible(NULL) and is called for side effects. rigger() returns a list containing the arguments, with the class "rigger" to enable +.rigger and print.rigger

Examples

# explode a simple call
boom(subset(head(mtcars, 2), qsec > 17))

# clock calls and customize how to print output
boom(subset(head(mtcars, 2), qsec > 17), clock = TRUE, print = str)

# print str only for data frames
boom(subset(head(mtcars, 2), qsec > 17), print = list(data.frame = str))

# rig an existing function
rig(ave)(warpbreaks$breaks, warpbreaks$wool)

# rig an anonymous function
fun1 <- rigger() + function(x) x + 1 + 2 # same as rig(function(x) x + 1 + 2))
fun1(1)
fun2 <- rigger(TRUE, typeof) + function(x) x + 1 + 2
fun2(1)

[Package boomer version 0.2.0 Index]