Ok sorry, this was a dumb error, I simply had overseen the method envRefClass$copy()
. So the solution is to call data.table::copy
explicitly:
dummy <- setRefClass(
"dummy",
fields = list(
dt = "data.table"
),
methods = list(
initialize = function( df ){
if( !missing( df ) ){
dt <<- data.table( df , key = "a" )
}
},
getTab = function( ix ){
return( data.table::copy(dt[ ix, ]) )
}
)
)