[datatable-help] Integration with magrittr

Steve Lianoglou lianoglou.steve at gene.com
Tue Jun 30 22:06:47 CEST 2015


Hi,

> I love data.table and I also love magrittr.

I really love both of these, too.

> However, some things don't work,
> e.g.
>
> DT <- data.table(a = 1:3, b = 4:6)
> DT[, a %<>% `*`(2)]    # instead of DT[, a := a %>% `*`(2)]

In my personal opinion, though, I feel like this might be going a
stretch too far.

Although this might just be a contrived example, it's hard for me to
divine an instance where this would look any less contrived. I mean,
is:

DT[, a %<>% `*`(2)] ## or
DT[, a := a %>% `*`(2)]

Really any more useful/simpler than:

DT[, a := a * 2]

Can't think of when I'd prefer the magrittr'ized version ... perhaps
when the column name (`a`) is actually a much longer? (so that %<>%
saves you some typing), or?

-steve

-- 
Steve Lianoglou
Computational Biologist
Genentech


More information about the datatable-help mailing list