title: faster way to multiply each entry by a column
body: <p>I have a data frame g with 3 columns, a, b and X. I need to multiply X with each entry in a and add to b to create a new variable. Right now i'm using a for loop</p>
  
  <pre><code>for(i in 1:N) {
      g$Eout[i] = mean((g$a[i]*g$X+g$b[i]-(g$X)^2)^2);
  }
  </code></pre>
  
  <p>which is really slow in R. Is there anyway to do this faster?</p>