GenericClass | R Documentation |
R6
class with generic (abstract) new cloning functionality.
object_generator
Class object generator used to create new clones, particularly for user inheritance.
attached
A list of dynamically attached attributes (name-value pairs).
new()
Initialization method saves an object generator for new cloning.
GenericClass$new(object_generator = NULL, ...)
object_generator
Class object generator used to create new clones, particularly for user inheritance.
...
Parameters passed individually (ignored).
new_clone()
Creates a new (re-initialized) object of the current (inherited) object class with optionally passed parameters.
GenericClass$new_clone(...)
...
Parameters passed via the inherited class constructor (defined in initialize and run via new).
New object of the current (inherited) class.
clone()
The objects of this class are cloneable with this method.
GenericClass$clone(deep = FALSE)
deep
Whether to make a deep clone.
object1 <- GenericClass$new()
class(object1)
# Referencing
object_ref <- object1
object_ref$attached$a <- 1
object1$attached
# Cloning
object2 <- object1$clone()
object2$attached$b <- 2
object1$attached
object2$attached
# New cloning
object3 <- object1$new_clone()
object3$attached$c <- 3
object1$attached
object3$attached
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.