These first three lines of code set the value of the parameters
of model, which are N0, r, and K.
Feel free to repeat the code using different values of these
parameters to see how the model’s
output changes.
K<-300 # Sets carrying capacity
r<-0.5 # Sets maximum rate of growth
N<-5 # Sets starting population size
We will run our population out for 50 time steps by defining the
time object
time<-50 # Sets number of time steps to run model
The following code calculates the above Verhulst-Pearl equation
using the specified parameters.
The if() function is making sure that the population is constrained
at carrying capacity (K).
t<-seq(1:time)
Nt<-(K*N*exp(r*t))/(K+N*(exp(r*t)-1))
L<-signif((K+50),1)
if(max(Nt)>L){L<-signif((max(Nt)+50),1)}
We can now plot the results using the plot() function using a line
plot (type=’l’).
plot(t,Nt,type='l',xlab='Time (Years)',ylab='Population
Size',col='blue',ylim=c(0,L),lwd=2)
These first three lines of code set the value of the parameters of model, which are N0, r, and K. Feel free to repeat th
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am