# [R] Population model question

-Halcyon- Cyonora at gmail.com
Tue Jan 15 09:37:04 CET 2008

```Hi all,

I have a population in which I want to follow living and dead animals
through time ( 1 simulation, 100 years). I have created 2 arrays for living
In the starting population there are, say, 500, animals
To determine whether each of these animals survives to a following
age-class, a uniformal chance is generated, resulting in "TRUE" if the
animal lives, or "FALSE" if it dies

Live.Animals <- array (FALSE, c(MaxAnimals, Years))
Dead.Animals <- array (FALSE, c(MaxAnimals, Years))

MaxAnimals <- 5000   ## max animals in the pop.
Years <- 100     ## years in the simulation

Live.Animals[,yy]    <- ifelse ((runif(MaxAnimals,0,1) < sur.age) &
Live.Animals[,yy-1], TRUE, FALSE)
## Live.Animals [,yy-1] : Animal had to be alive the year before
## sur.age : survival of each age class

Now, the array LiveAnimals is filled throughout the years with more and more
animals surviving( "TRUE") (and being born but those formulae are not in
this post)
My question is : How do I arbitrarily assign the animals being "FALSE"
***according to the uniformal chance generation*** to the array