November 27, 2018 | Published by | ,

by James Goldie Everybody’s least favourite part of programming is debugging. You spend days carefully putting a model or analysis together, press Run, cross your fingers, wait for hours, and then… an indecipherable error. Or your model is telling you that Sydney will be a balmy -999 °C. Cue hours of frustration and hair-pulling. R is a powerful and rapidly evolving programming language for researchers who need to do statistics and data analysis. But as we learn to work with larger sets of data, these errors, warnings and other ‘side effects’ become harder to find and manage. Was it the 37th statistical model that went wrong, or the 104th? This is particularly bad if you have one or two problem cases: there’s nothing worse than losing hundreds of results because one bit of data didn’t want to play ball. The collateral package aims to ease this pain. You can repeat a potentially risky operation—building a statistical model, rendering a plot, computing a tricky index—on as many groups of data as you want, and collateral will quickly show you which groups ended with errors, which ones returned results, and which ones finished but printed warnings or other messages. It’ll even tell you this in colour, so any sneaky errors should stand out right away:

Because collateral is designed to work with the tidyverse set of tools (although it’s not required), you can keep these side effects and results alongside any metadata or group identifiers you have and then go on to do more analysis, keeping everything together. Collateral also throws in helpers to filter or summarise on side effects, so if you do need your analysis to intervene when too many groups fail or complain (eg. automated testing), that’s easy to do. Collateral is available on CRAN, so you can install it as you would any other R package: install.packages(“collateral”)

It also comes with a vignette that introduces you to tidy workflows and shows you how to handle errors and side effects. If you have any ideas or feature requests, I’d love to hear them! You can get in touch with me or file an issue on GitHub. Hopefully it keeps some of your hair intact!