Re: [R] Trouble with a loop

2012-03-05 Thread Joshua Wiley
Hi Kerry, Right now at each iteration, you just overwrite everything. If you want a matrix, you need to instantiate Score as a matrix and then assign the results into each element of it. That said, I do not think you really need a loop. rpois() is vectorized, so you can in one pass generate a l

[R] Trouble with a loop

2012-03-05 Thread kerry1912
I am trying to run this loop but it keeps coming up with the following error: 'Error: no function to return from, jumping to top level' n.simul <- 1000 A <- {for(i in 1:12){{ nT <- rpois(n.simul, T[i]) nP <- rpois(n.simul, P[i]) nD <- rpois(n.simul, D[i]) nC <- rbinom(n.simul, nT, C[i]) Score <-