title: Call apply-like function on each row of dataframe with multiple arguments from each row
body: <p>I have a dataframe with multiple columns.  For each row in the dataframe, I want to call a function on the row, and the input of the function is using multiple columns from that row.  For example, let's say I have this data and this testFunc which accepts two args:</p>
  
  <pre><code>&gt; df &lt;- data.frame(x=c(1,2), y=c(3,4), z=c(5,6))
  &gt; df
    x y z
  1 1 3 5
  2 2 4 6
  &gt; testFunc &lt;- function(a, b) a + b
  </code></pre>
  
  <p>Let's say I want to apply this testFunc to columns x and z.  So, for row 1 I want 1+5, and for row 2 I want 2 + 6.  Is there a way to do this without writing a for loop, maybe with the apply function family?</p>
  
  <p>I tried this: </p>
  
  <pre><code>&gt; df[,c('x','z')]
    x z
  1 1 5
  2 2 6
  &gt; lapply(df[,c('x','z')], testFunc)
  Error in a + b : 'b' is missing
  </code></pre>
  
  <p>But got error, any ideas?</p>
  
  <p><strong>EDIT:</strong> the actual function I want to call is not a simple sum, but it is power.t.test.  I used a+b just for example purposes.  The end goal is to be able to do something like this (written in pseudocode):</p>
  
  <pre><code>df = data.frame(
      delta=c(delta_values), 
      power=c(power_values), 
      sig.level=c(sig.level_values)
  )
  
  lapply(df, power.t.test(delta_from_each_row_of_df, 
                          power_from_each_row_of_df, 
                          sig.level_from_each_row_of_df
  ))
  </code></pre>
  
  <p>where the result is a vector of outputs for power.t.test for each row of df.</p>