title: How to run more than one outer loop at time?
body: <p>Is there a way for me to to run the outer loops simultaneously without mess with the inner loops?</p>
  <p>I'm loosing the data.table performance if I use loops this way?</p>
  <p><strong>Note:</strong> I know there is some data.table functions that makes combinations like ones that I made, but they don't work for what I'm planning to do.</p>
  <pre><code>library(data.table)
  library(MASS)
  data(Insurance)
  x &lt;- setDT(Insurance)
  names(x) &lt;- tolower(names(x))
  x[,`:=`(district_group = 'A')][district == 1 | district == 4, `:=` (district_group = 'B')]
  vars &lt;- c('group','age')
  comb &lt;- do.call(&quot;c&quot;, lapply(seq_along(vars), function(i) combn(vars, i, FUN = list)))
  comb[[length(comb)+1]] &lt;- character(0)
  d &lt;- c('district','district_group')
  
  tmp &lt;- list()
  
  for(i in seq_along(d)){
    for(j in seq_along(comb)){
      y &lt;- copy(x)
      y &lt;- y[,.(nclaims=sum(claims), region = d[i]), by = c(d[i],comb[[j]])]
      setnames(y,old = d[i], new = 'region_id')
      tmp[[j]] &lt;- y
      
    }
    if(i==1){
      tbl &lt;- rbindlist(tmp, fill = TRUE)
    }
    if(i &gt; 1){
      tbl &lt;- rbindlist(list(tbl, rbindlist(tmp, fill = TRUE)), fill = TRUE)
    }
  }
  
  for(j in seq_along(tbl)){
    set(tbl, which(is.na(tbl[[j]])),j,'#')
  }
  </code></pre>