title: Error in integrate(f): evaluation of function gave a result of wrong length
body: <p>I am using R to do some multivariate analysis. For this work I need to integrate the trivariate PDF. While doing this I got the error:</p>
  
  <pre><code>Error in integrate(Vectorize(function(x) { : 
    evaluation of function gave a result of wrong length
  </code></pre>
  
  <p>As you could see, vectorize is not the solution so something wrong is going on.</p>
  
  <p>If somebody can give me a hint about what is going on, I'll really appreciate it.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>library(mvtnorm)
  f1&lt;-function(x, y, z) {dmvnorm(x=as.matrix(cbind(x,y,z)), mean=mu.t, sigma)} #PDF with all three
  #integrate out x
  integrate(Vectorize(function(x) {f1(x=c1, y=c2, z=c3)}), 0.1,0.5, rel.tol=1.5e-20)$value
  </code></pre>