The following is an example that has been scaled down. I am looking for an answer that corrects the following syntax, rather than a "work-around."
set.seed(1)
dt = data.table(sum1=rnorm(10,0,1),sum2=rnorm(10,2,1))
catsummax = c(0,3)
df
sum1 sum2
1: -0.6264538 3.5117812
2: 0.1836433 2.3898432
3: -0.8356286 1.3787594
4: 1.5952808 -0.2146999
5: 0.3295078 3.1249309
6: -0.8204684 1.9550664
7: 0.4874291 1.9838097
8: 0.7383247 2.9438362
9: 0.5757814 2.8212212
10: -0.3053884 2.5939013
for(i in 1:2){
dt=dt[paste0('sum',i)<=catsummax[i]]
}
This drops everything though because data table hates the syntax.
This only keeps rows that, in the first column are <= the first cat sum element, then, only keeps rows that also satisfy the second column's cat max, so it should give out:
df
sum1 sum2
3: -0.8356286 1.3787594
6: -0.8204684 1.9550664
10: -0.3053884 2.5939013