Skip to content
Prev 273983 / 398506 Next

multicore by(), like mclapply?

Hi Ivo,

My suggestion would be to only pass lapply (or mclapply) the indices.
That should be fast, subsetting with data table should also be fast,
and then you do whatever computations you will.  For example:

require(data.table)
DT <- data.table(x=rep(c("a","b","c"),each=3), y=c(1,3,6), v=1:9)
setkey(DT, x)

lapply(as.character(unique(DT[,x])), function(i) DT[i])

the DT[i] object is the subset of the data table you want.  You can
pass this to whatever function for computations you need.

Hope this helps,

Josh
On Mon, Oct 10, 2011 at 10:41 AM, ivo welch <ivo.welch at gmail.com> wrote: