[datatable-help] use of data.table in an S4 class
Steve Lianoglou
lianoglou.steve at gene.com
Sat Jan 30 15:02:46 CET 2016
Hi,
> # create a TestObj
> lala <- new("TestObj", id = "test", dt = data.table(a=1:10, b=11:20))
>
> # accessing the data.table slot results in a copy :-(
> lala at dt <- lala at dt[, c1 := a + b]
You are reassigning to the object here, what if you were to do this:
R> lala at dt[, c1 := a + b]
Accessing S4 object directory via their slot (ie using @) is
discouraged, but I'm not how it would work if you did the same using a
function. For example you might create a function `dt` that returns
the object in the @dt slot then work on it directly:
R> dt(lala)[, c1 := a + b]
Perhaps you can play with those and let us know if either is satisfactory?
-steve
--
Steve Lianoglou
Computational Biologist
Genentech
More information about the datatable-help
mailing list