[datatable-help] updating subsets

Sebastian Fischmeister sfischme at uwaterloo.ca
Mon Jul 20 17:39:01 CEST 2015


Hi,

I'm trying to split a data.table and then update the individual
splits. Does anyone have an idea, why this doesn't work?

Thanks,
  Sebastian



library(data.table)

## this doesn't work
q <- list(data.table(runif(9)),data.table(runif(9)))
lapply( q, function(xx) { qq <- split(xx, 1:nrow(xx) %/% 5)
                          lapply(qq, function(xx) { xx[, freq:=.N, by="V1"] })
                      })

## this doesn't work either although freq now exists
q <- list(data.table(runif(9)),data.table(runif(9)))
lapply(q, function(xx) xx[,freq:=-1] )
lapply( q, function(xx) { qq <- split(xx, 1:nrow(xx) %/% 5)
                          lapply(qq, function(xx) { xx[, freq:=.N, by="V1"] })
                      })





More information about the datatable-help mailing list