A package that extends flexyBayes calls fb_register_refusals() from its
own .onLoad() to add the reasons it refuses with. Its users then catch
those refusals with the same flexybayes_refusal condition class as the
core's, find them in fb_refusals(), and the package raises them with
fb_refuse().
Arguments
- refusals
A data frame with one row per reason and these character columns:
reason_code(required): lower-case letters, digits and underscores, starting with a letter. Prefix codes with something particular to the package so they do not collide with others.description(required): one sentence on what the refusal means, shown byfb_refusals()and used byfb_refuse()when no message is given.since_version(required): the package version that introduced the reason.message_template(optional, default"%s"): the message shape, for documentation.registered_in_adr(optional, defaultNA): the design record the reason traces to.plan_field(optional, defaultNA): thefb_plan()slot that reports the refusal before a fit, if any.
- package
The package that owns the reasons.
NULL(default) takes the package whose code makes the call, which is the right value inside.onLoad(). Outside a package it must be given.
Details
Each package's reasons go into a partition named after the package.
A reason code is unique across all partitions: a code that flexyBayes or
another package already registered is refused, and so is any attempt to
register under the name "flexyBayes". Registering the same code again
from the same package with identical fields does nothing, so a package
can be loaded twice in one session. Registering it with different fields
is refused. A table that fails any check registers none of its rows.
See also
fb_refuse() to raise a registered reason, fb_refusals() to
list them.
Examples
if (FALSE) { # \dontrun{
# In the plug-in's R/zzz.R:
.onLoad <- function(libname, pkgname) {
flexyBayes::fb_register_refusals(
data.frame(
reason_code = "mypkg_threshold_negative",
description = "The threshold must be zero or positive.",
since_version = "0.1.0"
)
)
}
} # }