#Project sizes of population growing at finite rate R = 1 +r #By R. Gomulkiewicz initial.size <- 100 #starting populatio size r <- 0.01 #intrinsic rate of increase #next.size <- initial.size*(1+r) #create a list to hold all the population sizes at all the steps steps <- 10 next.size <- matrix(0, steps+1, 1) #store the initial population size next.size[1,1] <- initial.size #this is a function that computes the population size at the next time step next.size.function <- function(n, r) {n*(1+r)} #this is a "loop" that projects the population sizes at all steps for(i in 1:steps){ next.size[i+1,1] <- next.size.function(next.size[i,1],r) } #plot the results plot(-5:5,next.size,xlab="steps",ylab="population size",type="b")