Object conformance checking made easy.
You can install the released version of checkr from CRAN with:
install.packages("checkr")
And the development version from GitHub with:
# install.packages("devtools")
devtools::install_github("kkmann/checkr")
This is a basic example which shows you how to solve a common problem:
library(checkr)
f <- function(positive) {
evaluate(ge(0), positive)
# we need to do something useful (throw errors etc later)
}
f(1)
[1] NA
f(-1)
[1] "positive: -1.000e+00 < 0.000e+00"
works for arrays as well:
g <- function(some_array = matrix(1:4, nrow = 2)) {
evaluate(ge(3), some_array)
}
cat(g())
some_array[1, 1]: 1.000e+00 < 3.000e+00
some_array[2, 1]: 2.000e+00 < 3.000e+00