R, Integrate at each point of array
问题 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. Here's what I did up to now: Integrand = function(s,x) { 1/4*(abs(x-s)<=1)*(abs(s)<=1) } MyConvolve = function(func,data) { return( integrate(func, lower=-Inf, upper=Inf, data) ) } Now, running the code with some array, I get an error message: SomeMatrix = replicate(10, rnorm(10)) MyConvolve