The Theory of Ecological Communities

R code for Chapter 6: Simulating Dynamics in Ecological Communities

By: Andrew MacDonald & Mark Vellend
Book by Mark Vellend, 2016, Princeton University Press


Chapter 6 in "The Theory of Ecological Communities" contains simulations of the dynamics of simple ecological communities. Provided here is the annotated R code with which readers can get started with simulations of their own. Code can be cut and paste from these web pages directly into an R script.

Boxes 3 and 4 have parameter values set to match those in one particular figure. For all other Boxes, readers are required to alter parameter values in order to match particular figures of figure panels. Relevant parameter values are described in each Box.

Contributions: Mark Vellend wrote the basic R code for running simulations. Andrew MacDonald used R Markdown to produce the vignettes that appear in these htm files, the revision of which was done collaboratively.

Click the links below to see the R code.

Online Box 1. R code for simulating neutral dynamics in a local, two-species community.

Online Box 2. R code for simulating dynamics with or without constant and frequency-dependent selection in local, two species communities: Figures 6.1, 6.2, 6.3 and 6.6 in the book.

Online Box 3. R code to simulate temporally fluctuating selection: Figure 6.4.

Online Box 4. R code for simulating delayed negative frequency-dependent selection: Figure 6.5 in the book.

Online Box 5. R code to simulate drift, selection, and dispersal of two species in any number of patches: Figures 6.7-6.9 in the book.

Online Box 6. R code to simulate a colonization-competition tradeoff model in 2 patches: Figure 6.10 in the book.

Online Box 7. R code to simulate a neutral model in one large community with speciation: Figure 6.11.

Online Box 8. R code to simulate the Theory of Island Biogeography: Figure 6.12 in the book.