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 < [email protected]> 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 > [email protected] > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help >
_______________________________________________ datatable-help mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
