Re: [R] integrate (error: evaluation of function gave a result of wrong length)

2012-02-15 Thread Uwe Ligges
On 15.02.2012 17:33, Dimitris.Kapetanakis wrote: Dear all, I am trying to use the integrate function in R but it seems that it does not work in my example and I cannot figure out why. I create a function Mu1 (which works fine) and try to integrate by the code: n <- 100 Ctrl<

Re: [R] integrate (error: evaluation of function gave a result of wrong length)

2012-02-15 Thread R. Michael Weylandt
Integrate works on functions that are vectorized (i.e., the algorithm puts in N inputs and expects N outputs) -- your function is not vectorized (and I'm not sure what integrating it means, but I'm not looking too closely) but you can make it "look vectorized" with the Vectorize() HOF. Note that th

[R] integrate (error: evaluation of function gave a result of wrong length)

2012-02-15 Thread Dimitris.Kapetanakis
Dear all, I am trying to use the integrate function in R but it seems that it does not work in my example and I cannot figure out why. I create a function Mu1 (which works fine) and try to integrate by the code: n <- 100 Ctrl<- as.matrix(cbind(runif(n, -30, 30))) W