我有一个R6类,其中包含一个data.table
属性。假设它看起来像这样:
library(R6)
library(data.table)
foo <- R6Class(
classname = 'foo',
public = list(
dt = NA,
initialize = function(dt) {
self$dt <- dt
}
)
)
set.seed(123)
dt <- data.table(col1 = rnorm(10), col2 = rnorm(10))
bar <- foo$new(dt)
我希望能够实现以下目标:
bar[<data.table stuff>]
这个做什么:
bar$dt[<data.table stuff>]
这是可能的吗?