Title: | Create View Tabs of Pipe Chains |
---|---|
Description: | Debugging pipe chains often consists of viewing the output after each step. This package adds RStudio addins and two functions that allow outputing each or select steps in a convenient way. |
Authors: | David Ranzolin [aut, cre, ctb], Joachim Gassen [aut] |
Maintainer: | David Ranzolin <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2024-10-09 03:13:00 UTC |
Source: | https://github.com/daranzolin/viewpipesteps |
%P>%
Prints and pipesThis pipe variant prints the object received from the left hand side prior to piping it to the right hand side.
lhs %P>% rhs
lhs %P>% rhs
lhs |
The left hand side of the pipe. |
rhs |
The right hand side of the pipe. |
called for side effects
This code is experimental. Use at your own risk.
if (!require(dplyr)) stop("Examples need dplyr to run") mtcars %>% filter(am == 1) %P>% select(qsec)
if (!require(dplyr)) stop("Examples need dplyr to run") mtcars %>% filter(am == 1) %P>% select(qsec)
Added as last command to a pipe, prints for each pipe step the resulting object to the console if unique. Data frames are converted by as_tibble().
print_pipe_steps(.data, cmd = print_command, all = FALSE)
print_pipe_steps(.data, cmd = print_command, all = FALSE)
.data |
The data, normally handed over from the prior pipe step. |
cmd |
The command to be evaluated for each object. Takes ps object of step example. |
all |
Whether you want to print objects even if they are identical. Helpful when you want to display changes in grouping. |
The unchanged data
if (!require(dplyr)) stop("Examples need dplyr to run") mtcars %>% filter(am == 1) %>% select(qsec) %>% print_pipe_steps() -> result my_print_cmd <- c( "message(title);", "skimr::skim_tee(data = ps%d)" ) mtcars %>% select(am, hp, mpg) %>% group_by(am) %>% print_pipe_steps(my_print_cmd, all = TRUE) %>% summarize( nobs = n(), mean_hp = mean(hp), mean_mpg = mean(mpg) )
if (!require(dplyr)) stop("Examples need dplyr to run") mtcars %>% filter(am == 1) %>% select(qsec) %>% print_pipe_steps() -> result my_print_cmd <- c( "message(title);", "skimr::skim_tee(data = ps%d)" ) mtcars %>% select(am, hp, mpg) %>% group_by(am) %>% print_pipe_steps(my_print_cmd, all = TRUE) %>% summarize( nobs = n(), mean_hp = mean(hp), mean_mpg = mean(mpg) )
Reads the currently selected text from the RStudio API and prints for each pipe step the resulting object if unique. Data frames are converted by as_tibble(). Meant to be called as an RStudio addin.
Reads the currently selected text from the RStudio API and prints for each pipe step the resulting object if unique. Data frames are converted by as.tibble(). Meant to be called as an RStudio addin.
printPipeChain() printPipeChain()
printPipeChain() printPipeChain()
No return value, called for side effects
Reads the currently selected text from the RStudio API and displays a data view in the source pane for each pipe step creating a unique object. Meant to be called as an RStudio addin.
Reads the currently selected text from the RStudio API and displays a data view in the source pane for each pipe step creating a unique object. Meant to be called as an RStudio addin.
viewPipeChain() viewPipeChain()
viewPipeChain() viewPipeChain()
No return value, called for side effects