title: Divide list of columns by a second list of columns
body: <p>I have script that generates a <code>data.table</code> with some columns I want to divide by some other columns and store the results in new columns. Here's an example.</p>
  <pre><code>library(data.table)
  dt &lt;- data.table(V1 = c( 5.553465,  4.989168,  2.563682,  6.987971, 19.220936),
                   V2 = c(4.248335, 19.768138,  3.840026, 17.411003, 17.939368),
                   V3 = c(9.683953, 15.344424, 11.729091,  7.534210,  5.404000),
                   V4 = c(5.949093,  4.553023,  9.765656, 11.211069,  4.085964),
                   V5 = c(11.814671,  5.460138,  2.492230,  1.48792,  8.164280))
  
  list1 &lt;- list(c(&quot;V1&quot;, &quot;V2&quot;, &quot;V3&quot;))
  list2 &lt;- list(c(&quot;V2&quot;, &quot;V4&quot;, &quot;V5&quot;))
  listRatio &lt;- list(c(&quot;rat1&quot;,&quot;rat2&quot;,&quot;rat3&quot;))
  </code></pre>
  <p>I have tried a variety of approaches to dividing the values in the list1 elements by the values in the list2 elements, unsuccessfully. Two are below; neither works.</p>
  <pre><code>dt[, (listRatio) := list1/list2]
  dt[, c(&quot;rat1&quot;,&quot;rat2&quot;,&quot;rat3&quot;) := mapply(dt, function(x,y) x / y, x = c(V1, V2, V3),  y = c(V2, V4, V5))]
  </code></pre>