Re: [datatable-help] Sum of sets of columns in data.table

2015-12-09 Thread Santosh Srinivas
Hello All, I am sure there is a much more efficient way to do this. Please advise any suggestions. For now, I have boot fixed this the crude way :-( age_brackets <- c("pop_0:pop_3","pop_4:pop_6","pop_7:pop_9") for (i in age_brackets) { cmdText <- paste('dt[, paste("",i,sep=""):= rowSums(.SD,

[datatable-help] subset data table in i with multiple criteria for multiple variables

2015-12-09 Thread carlsutton
Is there a way to subset a data table using "i" with multiple criteria using multiple variables(columns)? I have some test code shown below on what I have tried. And yes, I have read the documentation, taking the data camp class (Multiple viewing, I'm a slow learner) and have not seen anything

Re: [datatable-help] Sum of sets of columns in data.table

2015-12-09 Thread Bacou, Melanie
I come across this problem on a regular basis as well, and always end up fiddling for a while. Because the LHS of `:=` is also dynamic, I'm not sure there's any more elegant approach. One alternative might be to create several temporary data.tables holding the rowSums and then cbind()? for (i

Re: [datatable-help] subset data table in i with multiple criteria for multiple variables

2015-12-09 Thread carlsutton
 Gosh that is simple, elegant and wonderful.  Feel kinda sorta silly for not thinking of it.   Thank you for enlightening me. My Dad once said if there was a hard way to do a simple task, he was confident I would find it.  That malady has stuck with me oh so many years.  But in 10 years as an