Population modelling including spatially explicit models.
Abstract R is an open-source statistical environment modelled after the previously widely used commercial programs S and S-Plus, but in addition to powerful statistical analysis tools, it also provides powerful graphics outputs. R can be used for some quite fast modelling jobs but its speed is nowhere near that of a compiled programming language such as C++. This chapter shows how user-defined functions can be used to perform highly repetitive jobs efficiently, and demonstrates various mathematical functions. The first example shows how a vector can be incremented and the calculated points plotted on a graph as the simulation proceeds. The second example runs a loop, and each time passes values to a user-defined function, and receives back multiple values from that function, which it then stores for plotting later. The third example is necessarily more complex and shows how R code can be used to carry out spatially explicit analyses. Finally, a simple example shows how R can be used to teach how evolution takes place, even in the absence of natural selection due to genetic drift and population bottle-necking.