title: Using lapply to run exact binomial test over rows of a data frame
body: <p>I am trying to run a exact test to compare the observed vs. expected over many different pairs of observations and expectations.</p>
  
  <p>For each row, I want to compare <code>data$readCount</code> to <code>data$refFraction</code> to the constant number of <code>trials</code> (which is the sum of all of the <code>data$readCounts</code>).</p>
  
  <p>The way I was considering doing this is</p>
  
  <pre><code>test &lt;- function(x, p, n){binom.test(x, n, p, alternative="two-sided")}
  result &lt;- lapply(data[c("readCount", "refFraction")], test, n=trials)
  </code></pre>
  
  <p>But this gives me the error <code>incorrect length of 'x'</code></p>
  
  <p>Am I on the right track, or is there a better way to apply a function that compares two values in each row of a data frame (that has other members)?</p>