Trying to use a for loop for population simulation(2)
<p>Im sorry to say that I have a problem with a for loop, again. I'm trying to save the final number from a population estimate for loop into a new matrix but I am only able to get the population estimate to show up in row 100. I know it relates to breedingPop2 but I cant figure it out. Any help would be much appreciated. Please find the code below:</p>

<pre><code>finalPop=matrix(nrow=102, ncol=1)
for(i in 1:100){

SWWAyears=data.frame(iteration=rep(NA,101),pop=NA)
breedingPop&lt;-90000
fallMig&lt;-.825
springMig&lt;-.825
winterSurvival&lt;-rbeta(100,.95,.05)
npFecund&lt;-rbinom(100, 3.0, .9)
pFecund&lt;-rbeta(100, .85,.25)
breedingSurvival&lt;-rbeta(100,.95,.05)

# Set initial starting condition
SWWAyears[1,2]=breedingPop
for(years in 2:101) {
  fallPop&lt;-(SWWAyears[years-1,2]*fallMig)
  for (i in 1:100){
  winterPop&lt;-(fallPop*winterSurvival[i])}
  springPop&lt;-(winterPop*springMig)
        for (i in 1:100){
        summerPop&lt;-(springPop*breedingSurvival[i])
        }
            for(i in 1:100){
            breedingPop2&lt;-((summerPop*.26)*npFecund[i])+((summerPop*.14)*pFecund[i])+(summerPop*.60)
            }
  SWWAyears[years,1]=years
  SWWAyears[years,2]&lt;-breedingPop2             
}
finalPop[i,1]&lt;-breedingPop2
}
</code></pre>