title: Efficient multiplication of columns in a data frame
body: <p>I have a large data frame in which I am multiplying two columns together to get another column. At first I was running a for-loop, like so:</p>
  
  <pre><code>for(i in 1:nrow(df)){
      df$new_column[i] &lt;- df$column1[i] * df$column2[i]
  }
  </code></pre>
  
  <p>but this takes like 9 days.</p>
  
  <p>Another alternative was <code>plyr</code>, and I actually might be using the variables incorrectly:</p>
  
  <pre><code>new_df &lt;- ddply(df, .(column1,column2), transform, new_column = column1 * column2)
  </code></pre>
  
  <p>but this is taking forever</p>