This package provides a set of tools for data validation in R. This includes a variety of predicate functions to check properties of an R object with accompanying assertions.
You can install the development version of pure from GitHub with:
# install.packages("remotes")
remotes::install_github("functr/pure")
The following example uses pure to assert the input and output values of a function.
library(pure)
safe_divide_integers <- function(x, y) {
assert(is_pure_integer, is_scalar)(x)
assert(is_pure_integer, is_scalar, is_not_zero)(y)
assert(is_pure_double)(x / y)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.