pproto | R Documentation |
pproto
objectConstruct a new object with pproto
. This object system is inspired
from the ggproto
system used in the ggplot2
package.
pproto(`_class` = NULL, `_inherit` = NULL, ...)
_class |
Class name to assign to the object. This is stored as the class
attribute of the object. This is optional: if |
_inherit |
|
... |
A list of members to add to the new |
Adder <- pproto("Adder", x = 0, add = function(self, n) { self$x <- self$x + n self$x } ) Adder$add(10) Adder$add(10) Abacus <- pproto("Abacus", Adder, subtract = function(self, n) { self$x <- self$x - n self$x } ) Abacus$add(10) Abacus$subtract(10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.