Skip to content
Prev 277318 / 398506 Next

Very simple loop

But the awesome thing is you don't need a for loop at all thanks to
the magic of R's vectorization!

This will do it (and much faster than an R level loop would):

x = 0:200 # Note that you don't need a c() since you aren't
concatenating 0:200 with anything
A <- dpois(x,exp(4.5355343))
B <- dpois(x,exp(4.5355343 + 0.0118638))
C <- dpois(x,exp(4.5355343  -0.0234615))
D <- dpois(x,exp(4.5355343 + 0.0316557))
E <- dpois(x,exp(4.5355343 + 0.0004716))
F <- dpois(x,exp(4.5355343 + 0.056437))
G <- dpois(x,exp(4.5355343 + 0.1225822))

Y = A + B + C + D+ E+ F + G

plot(x, Y)

I'd advise you to look around for a good R guide: (there are quite a
few free online, many tailored to specific disciplines) vectorization
is pretty sweet and if you don't get into it early, you'll find R to
be much more cumbersome and slow than it truly is.

Hope this helps,

Michael
On Mon, Nov 14, 2011 at 10:59 AM, Davg <davidgrimsey at hotmail.com> wrote: