Description Usage Arguments Details Value Examples
This function adds to the existing call callback, rather than replace it, by putting a callback in front of it to be tested first. The callback will be invoked when the traversal sees a call to a specific function.
1 | add_call_callback(callbacks, fn, cb)
|
callbacks |
The existing callbacks. |
fn |
The function to which calls should be modified. |
cb |
The callback function to invoke. |
The callback that is installed will be called with the usual callback
arguments (which depend on context and user-provided information to
..., see rewrite_callbacks()
and analysis_callbacks()
), and additionally
the next callback in line, through the parameter next_cb
. This can be
used to propagate information through several callbacks in a pipe-like
fashion.
1 | The updated callbacks.
|
1 2 3 4 5 6 7 8 9 | f <- function(x) 2 + x
cb <- rewrite_callbacks() %>%
add_call_callback(f, function(expr, ...) {
quote(2 + x)
})
tr_f <- . %>% rewrite() %>% rewrite_with(cb)
g <- function(y) y + f(y)
tr_f(g)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.