title: Assign results of apply to multiple columns of data frame
body: <p>I would like to process all rows in data frame <code>df</code> by applying function <code>f</code> to every row. As function <code>f</code> returns numeric vector with two elements I would like to assign individual elements to new columns in <code>df</code>.</p>
  
  <p>Sample <code>df</code>, trivial function <code>f</code> returning two elements and my trial with using <code>apply</code></p>
  
  <pre><code>df &lt;- data.frame(a = 1:3, b = 3:5)
  
  f &lt;- function (a, b) {
    c(a + b, a * b)
  }
  
  df[, c('apb', 'amb')] &lt;- apply(df, 1, function(x) f(a = x[1], b = x[2]))
  </code></pre>
  
  <p>This does not work results are assigned by columns:</p>
  
  <pre><code>&gt; df
    a b apb amb
  1 1 3   4   8
  2 2 4   3   8
  3 3 5   6  15
  </code></pre>