register_model_type: Register a model type to class mapping

View source: R/class-register.R

register_model_typeR Documentation

Register a model type to class mapping

Description

Define how to map a model type to model or summary object names when the default mapping of {type} to ⁠bbi_{type}_model⁠ or ⁠bbi_{type}_summary⁠ won't do. The primary use for this function is registering custom parent types.

Usage

register_model_type(model_type, classes, class_type = c("model", "summary"))

Arguments

model_type

Model type, as recorded in the model YAML file.

classes

One or more classes to use for model_type.

class_type

The kind of object, "model" or "summary".

Details

create_model_object() and create_summary_object() are responsible for creating model and summary objects for different model types (e.g., "bbi_nonmem_model" and "bbi_nonmem_summary" for "nonmem" model types). These functions get the class name from model_type_to_classes(), which by default constructs the class from the model type (e.g., "nonmem" is mapped to c("bbi_nonmem_model", ...)).

That default value doesn't work if you want to define custom parents. For example, bbr.bayes package wants to map "nmbayes" model type to c("bbi_nmbayes_model", "bbi_nonmem_model", ...) so that bbi_nmbayes_model objects can fall back to .bbi_nonmem_model methods where appropriate. In these cases, a package can call register_model_type() within its .onLoad() to "register" the custom classes.

Examples

## Not run: 
register_model_type("foo",
                    c("bbi_foo_model", "bbi_nonmem_model"),
                    "model")
register_model_type("foo",
                    c("bbi_foo_summary", "bbi_nonmem_summary"),
                    "summary")

## End(Not run)


metrumresearchgroup/rbabylon documentation built on April 21, 2024, 3:26 a.m.