A drop-in replacement for %>% that logs row counts, column counts, added/dropped column names, and step timing at each stage of a dplyr / tidyr pipeline. Inspired by the SAS DATA step log and mostly for educational context in R.

Nested pipelines (e.g. inside a semi_join() or filter() argument) are automatically detected and displayed with increasing indentation, so the main pipeline and its sub-pipelines are visually distinct.

lhs %>=% rhs

Arguments

lhs

A data frame (or tibble) passed as the left-hand side.

rhs

An unevaluated dplyr-style function call.

Value

The result of applying rhs to lhs, invisibly from the logging perspective — the value is returned normally so pipelines compose as expected.

Details

Depth tracking uses options(.LPipe_depth) which is incremented around the evaluation of rhs only, ensuring that the steps of the main pipeline always log at depth 0 and nested %>=% calls at depth 1, 2, etc.

Display options (wrap_width, big_mark, lang) are controlled via logrittr_options().

Examples

if (FALSE) { # \dontrun{
library(dplyr)

logrittr_options(lang = "en", big_mark = ",", wrap_width = 30)

iris %>=%
  as_tibble() %>=%
  filter(Sepal.Length < 5) %>=%
  mutate(rn = row_number()) %>=%
  group_by(Species) %>=%
  summarise(n = n_distinct(rn))
} # }