| GenericModel | R Documentation |
R6 class with generic (abstract) functionality for toolset
models, including model attribute get and set methods that resolve attribute scope
(public, active, attached), attribute aliases, attribute
attachment, and error and warning message attributes.
poems::GenericClass -> GenericModel
attachedA list of dynamically attached attributes (name-value pairs).
model_attributesA vector of model attribute names.
attribute_aliasesA list of alternative alias names for model attributes (form: alias = "attribute") to be used with the set and get attributes methods.
error_messagesA vector of error messages encountered when setting model attributes.
warning_messagesA vector of warning messages encountered when setting model attributes.
new()Initialization method sets given attributes individually and/or from a list.
GenericModel$new( model_attributes = NULL, attribute_aliases = NULL, params = list(), ... )
model_attributesA vector of model attribute names.
attribute_aliasesA list of alternative alias names for model attributes (form: alias = "attribute") to be used with the set and get attributes methods.
paramsParameters passed via a list.
...Parameters passed individually.
new_clone()Creates a new (re-initialized) object of the current (inherited) object class with optionally passed parameters.
GenericModel$new_clone(...)
...Parameters passed via the inherited class constructor (defined in initialize and run via new).
New object of the current (inherited) class.
get_attribute_names()Returns an array of all attribute names including public and private model attributes, as well as attached attributes, error and warning messages.
GenericModel$get_attribute_names()
Array of all attribute names.
get_attributes()Returns a list of values for selected attributes or attribute aliases (when array of parameter names provided) or all attributes (when no params).
GenericModel$get_attributes(params = NULL)
paramsArray of attribute names to return (all when NULL).
List of selected or all attributes values.
get_attribute()Returns the value of an attribute via character name or attribute alias.
GenericModel$get_attribute(param)
paramCharacter string name of the attribute.
Attribute value.
get_attribute_aliases()Returns an array of attribute names and aliases for specified or all attributes.
GenericModel$get_attribute_aliases(params = NULL)
paramsArray of attribute names for names/aliases to return (all when NULL).
Array of selected or all attribute names and aliases.
set_attributes()Sets given attributes (optionally via alias names) individually and/or from a list.
GenericModel$set_attributes(params = list(), ...)
paramsList of parameters/attributes.
...Parameters/attributes passed individually.
clone()The objects of this class are cloneable with this method.
GenericModel$clone(deep = FALSE)
deepWhether to make a deep clone.
model1 <- GenericModel$new(
model_attributes = c("a", "b", "c"),
attribute_aliases = list(A = "a"),
params = list(a = 1, b = 2), c = 3
)
# Get/set attributes
model1$get_attribute_names()
model1$set_attributes(d = 4)
model1$get_attributes()
model1$get_attribute("A")
model1$get_attribute("B")
model1$get_attribute_aliases() # all attribute names
# New cloning
model2 <- model1$new_clone(e = 5)
model2$get_attributes()
model2$modelattributes
model2$attribute_aliases
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.