title: multiplying columns in R
body: <p>I have a data frame like this.</p>
  
  <pre><code>&gt; abc
     ID 1.x 2.x 1.y 2.y
  1   4  10  20  30  40
  2  16   5  10   5  10
  3  42  16  17  18  19
  4  91  20  20  20  20
  5 103 103  42  56  84
  </code></pre>
  
  <p>How do I create two additional columns '1' and '2' by multiplying 1.x * 1.y and 2.x * 2.y in a generalized way?</p>
  
  <p>I am trying to get a generalized solution where number of columns can be too many. So I want to multiply all x with all y. While x and y are fixed, n has to be figured out from data frame. </p>
  
  <p>For simplicity lets assume n is also fixed however it is a large number.</p>
  
  <p>One thing i can try is :-</p>
  
  <p><code>abc[,c(6,7)]=abc[,c(2,3)]*abc[,c(4,5)]</code> 
  It will work only if col positions are contiguous. This is good enough for me. If anyone can have more generalized solution, it will benefit us all.</p>