Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
63 lines (43 sloc) 2.57 KB
title: "goalie"
date: "`r BiocStyle::doc_date()`"
output: BiocStyle::html_document
vignette: >
abstract: Assertive check functions for defensive R programming.
```{r setup, include=FALSE, message=FALSE}
knitr::opts_chunk$set(message = FALSE)
# Introduction
[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:
- [assertive][] by Richie Cotton.
- [assertthat][] by Hadley Wickham.
- [checkmate][] by Michael Lang.
# The assert check engine
# Checking function inputs
# Creating new assert checks
# S4 class validity checks
# R session information
You can’t perform that action at this time.