title: R, Integrate at each point of array
body: <p>I'm stuck with computing the integral at each point of an array. The idea is first to create a function ("Integrand"). Then, create a second function ("MyConvolve") that computes the necessary integral.</p>
  
  <p>Here's what I did up to now:</p>
  
  <pre><code>Integrand = function(s,x)
  { 1/4*(abs(x-s)&lt;=1)*(abs(s)&lt;=1) }
  
  MyConvolve = function(func,data)
  { return( integrate(func, lower=-Inf, upper=Inf, data) ) }
  </code></pre>
  
  <p>Now, running the code with some array, I get an error message:</p>
  
  <pre><code>SomeMatrix = replicate(10, rnorm(10))
  MyConvolve(Integrand, SomeMatrix)
  </code></pre>
  
  <p>Which ends up with the following error message:</p>
  
  <pre><code>Error in integrate(func, lower = -Inf, upper = Inf, data) :
  evaluation of function gave a result of wrong length
  </code></pre>
  
  <p>I already tried vectorizing the function, but still ended up with error messages.</p>
  
  <p>Thank you very much for your help!</p>