I have just finished and released a free new R video lecture demonstrating how to use the “Bizarro pipe” to debug magrittr pipelines. I think R dplyr users will really enjoy it.
Please read on for the link to the video lecture.
In this video lecture I use the “Bizarro pipe” to debug the example pipeline from RStudio’s purrr announcement.
TLDnW (too long, did not watch) summary: To debug an R magrittr pipeline using R and RStudio:
- Reorganize your pipeline so each pipe is at the end of the line and make all “dot” uses explicit (i.e. replace things like
map(summary)withmap(., summary)). The diagram above illustrates this. - Replace all
magrittrpipes (“%>%“) with Bizarro pipes (“->.;“). - In RStudio “Preferences -> General” check “Show .Last.value”. This gives you a convenient view of the value of the last calculation (handy as “dot variables”, including “dot” are traditionally not shown).
You can now single step through your pipeline examining results as you go. If you hit an exception you can re-run that line again and again as the exception semantics cancel the assignment implied by the Bizarro pipe before the old value of “.” is lost.
The “secret” to grokking the Bizarro pipe is to train your eyes to see the “->.;” as a single atomic or indivisible glyph (ignoring the presence of “->” and “;“, both of which are forbidden in most style guides).
For a more detailed demonstration, please watch the video.
Categories: Exciting Techniques Statistics Tutorials
jmount
Data Scientist and trainer at Win Vector LLC. One of the authors of Practical Data Science with R.


Also, a “thank you” to Ista for being a strong early advocate of Bizarro pipe debugging.
LikeLike
Another Win-Vector LLC R debugging video: “Wrapper Functions” https://youtu.be/-P9UzQuJSH8
LikeLike
Maybe I’m missing something, but why not just do:
.<- babynames
.% substr(1, 3) %>% equals(“Ste”) )
.<- group_by(., year, sex)
.<- summarize(., total = sum(n))
.<- qplot(year, total, color = sex, data = ., geom = "line")
.<- add(., ggtitle('Names starting with "Ste"'))
print(.)
i.e. base R
LikeLike
Jesse,
Good point.
Actually Bizarro pipe is very much base-R as
deparse(substitute(5 ->.))returns". <- 5".LikeLike