print_pipe_steps: Prints the return objects of all pipe steps to console

Description Usage Arguments Value Examples

View source: R/print_pipe_steps.R

Description

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().

Usage

1
print_pipe_steps(.data, cmd = print_command, all = FALSE)

Arguments

.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.

Value

The unchanged data

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
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)
  )

daranzolin/ViewPipeSteps documentation built on Dec. 26, 2021, 6:12 p.m.