title: dplyr error "length(xmin) == 1 is not TRUE" with mutate when using the integral() function
body: <p>I have a data frame with as follows</p>
  <pre><code>lower &lt;- c(1,5,15)
  upper &lt;-c(5,15,30)
  df&lt;-data.frame(lower,upper)
  </code></pre>
  <p>I would like to use dplyr's mutate to create a new variable of the area under the curve of a defined function. The function is as follows.</p>
  <pre><code>my_fun &lt;- function(x){y = 1.205016 + 0.03796243 * log(x)}
  </code></pre>
  <p>I am using the <code>integral()</code>  function from the <code>pracma</code>  package to find the area under the curve. When I use this function on an a pair of upper and lower values it runs with no Errors as follows.</p>
  <pre><code>integral(my_fun, 1,5)
  [1] 4.973705`
  </code></pre>
  <p>However, when I try to run this same function using dplyr's mutate, I get the following.</p>
  <pre><code>new_df &lt;- df %&gt;%
     mutate(new_variable = integral(my_fun, lower, upper))
  </code></pre>
  <blockquote>
  <p>Error in integral(my_fun, lower, upper) : length(xmin) == 1 is not
  TRUE</p>
  </blockquote>
  <p>It seems that the <code>integral</code> function must be reading the whole vectors <code>df$lower</code> and <code>df$upper</code>rather than the individual pairs of values <code>1,5</code>. Is there a solution to this using dplyr's <code>mutate</code>, or should I be looking for other solutions.</p>
  <p>I did some looking around and the only instances of this error related to mutate did not seem to address the issue I have here.</p>