Assertive check functions for defensive R programming.


Bioconductor method

We recommend installing the package with BiocManager.

if (!require("BiocManager")) {

conda method

Configure conda to use the bioconda channels.

conda install -c bioconda r-goalie


goalie is an attempt to incorporate elements of multiple assertive check packages into a single package with as few dependencies as possible. All assertive checks are written in the most basic R code possible, without reliance on compilation (e.g. C++/Rcpp). It is still a work in progress, and feature requests are welcome.

R exports the stopifnot() function as a simple assert engine that supports multiple boolean returns (TRUE/FALSE) in a single call, separated by commas. This is a nice, flexible system for defensive programming. However, stopifnot() does not currently support custom error messages, and can be confusing to debug.

Similar to the approach used in the assertthat package, goalie exports the assert() function, which is designed to be a drop-in replacement for stopifnot() with improved error message support. validate() is a variation on assert() that is intended to be used within S4 class validity checks, which is useful for Bioconductor packages.

Additionally, goalie exports a number of assertive check functions that are intended to harden bioinformatics-oriented functions in R. These check functions return logical with an additional "goalie" S3 class definition, which enables us to define custom print methods that display additional useful information about the cause of the error (see cause() and print() for details). This approach draws heavily from the assertive package.

The goalie source code incorporates elements from these excellent assert check packages: