[R] Using integrate() with vectors as boundaries rather than scalars

2006-10-10 Thread Tobias
Hi all my apologies if above title is misleading, but here is my problem anyways: I need to evaluate an integral n times. Since I can't get my head around vectorization as of yet, I have coded it up in a loop, i.e.: for (i in 1:n) { z[i] - integrate(dnorm,x[i],Inf) } Since n is

Re: [R] Using integrate() with vectors as boundaries rather than scalars

2006-10-10 Thread Tobias
I think I have figured it out myself, would however like to know the opinion of more experienced coders. Is this a good way of approaching this: cumdnorm1 - function(x) {integrate(dnorm,x,Inf)} evalvec - function(x) {lapply(x,cumdnorm1)} It does return the desired result. Tobias wrote:

Re: [R] Using integrate() with vectors as boundaries rather than scalars

2006-10-10 Thread Gabor Grothendieck
Or just: lapply(x, integrate, f = dnorm, upper = Inf) On 10/11/06, Tobias [EMAIL PROTECTED] wrote: I think I have figured it out myself, would however like to know the opinion of more experienced coders. Is this a good way of approaching this: cumdnorm1 - function(x)