rm(list=ls()) p=.75; #fraction of cells that survive each reproduction generation_end=100; #predict up to this generation in the future K=2000; #reproduction capacity #Define list (vector) nvector, where nvector(t) is number of cells per generation #Dummy list -- all zeros nvector=rep(0,generation_end); nvector[1] = 1000; #initial number of cells (generation 0) for (t in 2:generation_end) nvector[t] <- 4*nvector[t-1]*p*(1 - nvector[t-1]/K) # way 1 vector_of_times_over_limit <- vector() for (t in 1:generation_end) if (nvector[t] > 30) vector_of_times_over_limit <- c(vector_of_times_over_limit, t) # way 2 vector_of_times_over_limit <- which(nvector[t] > 30) # plot! tvector=1:generation_end; plot(tvector, nvector, pch = 1, cex = 1, type = "b", main = "My First Plot in R", xlab = "t", ylab = "N(t)")