boom {boomer} | R Documentation |
Print the Output of Intermediate Steps of a Call
Description
-
boom()
prints the intermediate results of a call or a code chunk. -
rig()
creates a copy of a function which will display the intermediate results of all the calls of it body. -
rig_in_namespace()
rigs a namespaced function in place, so its always verbose even when called by other existing functions. It is especially handy for package development. -
rigger()
provides a convenient way to rig an anonymous function by using therigger(...) + function(...) {...}
syntax.
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 |
print |
A function, a formula or a list of functions or formulas, used to
modify the way the output is printed. Defaults to |
fun |
function ro |
... |
Functions to rig in their namespace If the rlang's formula notation is supported, so for instance you can type:
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 |
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)