[datatable-help] updating subsets

Frank Erickson fperickson at wisc.edu
Mon Jul 20 18:14:34 CEST 2015


Ah ok. mclapply is a little beyond my depth, but I think you can always put
the variable you are splitting by (1:nrow(xx) %/% 5 here) directly into the
by argument of xx[i,j,by], so...

q <- list(data.table(runif(9)),data.table(runif(9)))
lapply( q, function(xx) xx[, freq:=.N, by=.(V1,1:nrow(xx) %/% 5)] )

works for me, on data.table 1.9.4.

On Mon, Jul 20, 2015 at 11:55 AM, Sebastian Fischmeister <
sfischme at uwaterloo.ca> wrote:

>
>
> > I think you should use a single data.table; it's much more
> straightforward
> > in that case:
> >
> > qq <- data.table(runif(18),id=rep(1:2,each=9))
> > qq[,freq:=.N,by=.(id,seq(nrow(qq))%/%5)]
>
> Thanks for the idea, unfortunately I need lists. The example is just a
> minimal example to show the problem. The actual code will use large
> data.tables in lists and I want to eventually use mclapply to
> parallelize the computation.
>
>   Sebastian
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20150720/a1294f1c/attachment.html>


More information about the datatable-help mailing list