I am learning how to use R6 classes (and in general R OO).
In this tutorial I found an interesting way of presenting constructors. In section 6.3 a different kind of con
Since R6
classes are actually envoronments, you can use className$constructorName
to archieve this result.
library(R6)
ERes <- R6Class(
"ERes",
public = list(
eTable = NULL,
eList = NULL,
initialize = function(eTable, eList){
self$eTable <- eTable
self$eList <- eList
}
)
)
ERes$userConstructor <- function(someData){
ERes$new(table(someData), as.list(someData))
}
myObject <- ERes$userConstructor(rpois(100, 5))
myObject$eTable
# someData
# 0 1 2 3 4 5 6 7 8 10
# 3 3 7 16 16 20 14 10 9 2