View source: R/params_check_consistent.R
check_consistent | R Documentation |
If the parameters of a function are given in some combination but have
an interdependency (e.g. different parametrisations of a probability
distribution) or a constraint (like x>0
) this function can simultaneously
check all interrelations are satisfied and report on all the not
conformant features of the parameters.
check_consistent(..., .env = rlang::caller_env())
... |
a set of rules to check either as |
.env |
the environment to check in |
nothing, throws an informative error if the checks fail.
testfn = function(pos, neg, n) {
check_consistent(pos=n-neg, neg=n-pos, n=pos+neg, n>pos, n>neg)
}
testfn(pos = 1:4, neg=4:1, n=rep(5,4))
try(testfn(pos = 1:4, neg=5:2, n=rep(5,4)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.