debug_pipeline creates a function out of the input pipeline with each line running an additional step from the pipeline and calls the debugging browser on the function. Each line run prints to the console plus stores the result to a variable of the form dot[N], where [N] is the index of the element in the pipeline, so results can easily be replicated or adjusted in the debugging console.

debug_pipeline(pipeline, ...)

Arguments

pipeline

A pipeline. Can be an unquoted or quoted expression, or a character vector of code. If missing, uses the text highlighted in RStudio's source editor.

...

Only used to allow assignment with = at the beginning of a pipeline.

Details

debug_pipeline can also be called interactively in RStudio via the "Debug pipeline in browser" add-in after highlighting the pipeline to debug in the source editor.

For a full explanation of the special commands available in the debugging browser, see browser.

See also

Examples

# \donttest{ library(magrittr) debug_pipeline( x <- 1:5 %>% rev %>% {. * 2} %>% sample(replace = TRUE) )
#> dot1 <- rev(1:5) #> dot2 <- {dot1 * 2} #> x <- sample(dot2, replace = TRUE)debugging in: pipeline_function() #> debug: { #> print(dot1 <- rev(1:5)) #> print(dot2 <- { #> dot1 * 2 #> }) #> print(x <- sample(dot2, replace = TRUE)) #> } #> debug: print(dot1 <- rev(1:5)) #> [1] 5 4 3 2 1 #> debug: print(dot2 <- { #> dot1 * 2 #> }) #> debug: dot1 * 2 #> [1] 10 8 6 4 2 #> debug: print(x <- sample(dot2, replace = TRUE)) #> [1] 2 4 2 4 10 #> exiting from: pipeline_function()
# }