June 2007
Beginner to intermediate
950 pages
27h 8m
English
We need to solve a system of ordinary differential equations (ODEs) and choose to use the classical Runge–Kutta fourth-order integration function rk4 from the odesolve package:
install.packages("odesolve") library(odesolve)
The example involves a simple resource-limited plant herbivore where V = vegetation and N = herbivore population. We need to specify two differential equations: one for the vegetation (dV/dt) and one for the herbivore population (dN/dt):
![]()

![]()
The steps involved in solving these ODEs in R are as follows:
phmodel <-function(t, x, parms) { v<-x[1] n<-x[2] with(as.list(parms), { dv<-r*v*(K-v)/K - b*v*n dn<-c*v*n – d*n res<-c(dv, dn)
list(res) })} times <-seq(0, ...
Read now
Unlock full access