[This article was first published on Guillaume Pressiat, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)Want to share your content on R-bloggers? click here if you have a blog, or here if you don't. dplyr verbs are descriptive: let’s make them more verbose! Yet another pipe for R.Repost for better image handling on r-bloggers.MotivationIn SAS, every DATA step prints a log:NOTE: There were 120000 observations read from WORK.SALES.NOTE: 7153 observations were deleted.NOTE: The data set WORK.RESULT has 112847 observations and 11 variables.R’s dplyr pipelines are silent. logrittr fills that gap with %>=%, adrop-in pipe that logs row counts, column counts, added/dropped columns, andtiming at every step, with no function masking.With Fira Code ligatures, %>=% rendersas a single wide arrow visually similar to %>% with an underline added, like a subtitle or, say, to read between the lines of a pipeline (what happened).Multiples contextsThings happens:NOTE: There were 120000 observations read from WORK.SALES.NOTE: 120000 observations were deleted.NOTE: The data set WORK.RESULT has 0 observations and 11 variables.“It’s here we’ve lost all rows in script execution”.ProReading this a long time after execution of a script helps you see: what happened at each stage of data processing without having to rerun the code, for example in a production environment where the input data is constantly changing monitor key processes Make sure you can explain what happened (an audit, for example)In professional contexts it’s often needed.EducationalThis will also be clearer thanks to a console log for those with little experience with the tidyverse: people who are taking their first steps in programming by following a tutorial or teaching themselves.Installationinstall.packages('logrittr', repos = 'https://guillaumepressiat.r-universe.dev')# or from github# devtools::install_github("GuillaumePressiat/logrittr")See github or r-universe.Usagelibrary(logrittr)library(dplyr)iris %>=% as_tibble() %>=% filter(Sepal.Length < 5) %>=% mutate(rn = row_number()) %>=% semi_join( iris %>% as_tibble() %>=% filter(Species == "setosa"), by = "Species" ) %>=% group_by(Species) %>=% summarise(n = n_distinct(rn))── iris [rows: 150 cols: 5] ─────────────────────────────────────────────────────ℹ as_tibble() rows: 150 +0 cols: 5 +0 [ 0.0 ms]ℹ filter(Sepal.Length < 5) rows: 22 -128 cols: 5 +0 [ 3.0 ms]ℹ mutate(rn = row_number()) rows: 22 +0 cols: 6 +1 [ 1.0 ms] added: rnℹ > filter(Species == "setosa") rows: 50 -100 cols: 5 +0 [ 1.0 ms]ℹ semi_join(iris %>% as_tibble() %>=% rows: 20 -2 cols: 6 +0 [ 5.0 ms] filter(Species == "setosa"), by = "Species")ℹ group_by(Species) rows: 20 +0 cols: 6 +0 [ 3.0 ms]ℹ summarise(n = n_distinct(rn)) rows: 1 -19 cols: 2 -4 [ 2.0 ms] dropped: Sepal.Length, Sepal.Width, Petal.Length, Petal.Width, rn added: nScreenshotlibrary(dplyr)library(logrittr)logrittr_options(lang = "en", big_mark = ",", wrap_width = NULL, max_cols = 3)nycflights13::flights %>=% as_tibble() %>=% group_by(year, month, day) %>=% count() %>=% tidyr::pivot_wider(values_from = "n", names_from = "day") %>=% glimpse()Related package: tidylogtidylog is a really neat package that gives me motivation for this one.tidylog works by masking dplyr functions, which doesn’t seem ideal to me.Anyway this also was a moment for me to test a new programmer tool that is used a lot for programming at this time.logrittr uses a custom pipe operator and never touchesthe dplyr namespace. Its console output is colorful and informative thanks to the cli package.Working with lumberjackIf you already know the lumberjack package, compatibility is available with logrittr (timings are approximates).Calling logrittr_logger$new():library(lumberjack)library(dplyr)l % as_tibble() %L>% filter(Sepal.Length < 5) %L>% mutate(rn = row_number()) %L>% group_by(Species) %L>% summarise(n = n_distinct(rn)) %L>% dump_log(file=logfile, stop = FALSE) mtcars %>% start_log(log = l, label = "mtcars step") %L>% count() %L>% dump_log(file=logfile, stop = TRUE)logdata or in %>%. Take another pipe for a spinlogrittr prioritizes the user experience with a structured and colorful display in the console.For now, this package is just a proof of concept that gave me a chance to experiment a bit with the cli package and few other things. But I think there’s a need for that in R, in a specific area where SAS outputs are so informative. https://guillaumepressiat.r-universe.dev/logrittr https://github.com/guillaumepressiat/logrittrTo leave a comment for the author, please follow the link and comment on their blog: Guillaume Pressiat.R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.Continue reading: logrittr: A Verbose Pipe Operator for Logging dplyr Pipelines