On this page find details about changes to the support material for Community Ecology. These changes will include:
- alterations and improvements to custom R commands
- new custom R commands
- additional data
- extra exercises
The changes are listed below in date order (newest entries at the top). Alterations will be reflected in the existing support pages, essentially:
- Any altered or additional R commands will be added to the RData support file and the ZIP Archive found on the Support Files page.
- Any extra data will be added to the Zip Archive (and RData file if in R-format) found on the Support Files page. Notes about the custom commands will be updated in the Custom Commands page.
- Any extra exercises will be presented on the website (I will make new pages as required).
July 2021
Importing data with character variables
Since R version 4, data imported using read.table()
or read.csv()
functions do NOT have character
columns converted to factor
variables.
This means that examples where a factor
variable is assumed will not work as expected, and you will need to alter character
variables to factor
.
You can do this individually for each variable required for example:
names(pd) [1] "Site" "Species" pd$Site <- as.factor(pd$Site)
You can also convert all character
variables to factor
using the rapply()
function like so:
pd <- rapply(pd, f = as.factor, classes = "character", how = "replace")
In this case any columns that were originally character
would be converted to a factor
.
June 2015
New command to carry out Polar Ordination (aka Bray-Curtis ordination):
polar.ord()
This is a new command that conducts polar ordination (also called Bray-Curtis ordination). The book shows polar ordination and presents a method to carry it out using Excel (Chapter 14). This is labour intensive but instructive for students, as it shows some of the basic principles behind ordination in general. However, I thought it would be useful to have an R command to carry out the procedure.
The command works out polar ordination site scores and works out axes as follows: Axis 1 is the combination of sites that gives the maximum separation (not necessarily the maximum variance explained). Axis 2 is the combination of sites that maximises the orthogonality to the 1st axis.
There are print
, plot
and summary
methods and an identify
method for use with plots.
Usage
polar.ord(diss) print.polar.ord(ord, digits = getOption("digits")) summary.polar.ord(ord, k = 2, cor = TRUE, var.exp = TRUE, digits = getOption("digits")) plot.polar.ord(ord, x.axis = 1, y.axis = 2, type = c("t", "p", "n"), ...) identify.plot.polar.ord(pord, labels = pord$labels, ...)
diss |
A dissimilarity matrix e.g. as produced by dist() or vegdist() . |
digits |
The number of digits to display, defaults to current settings. |
ord |
The result of a polar.ord command. |
k |
The number of axes to display. |
cor |
If TRUE , shows the correlation between ordination axes. |
var.exp |
If TRUE , shows the variance explained. |
x.axis |
Which ordination axis to plot on the x-axis. |
y.axis |
Which ordination axis to plot on the y-axis. |
type |
The type of plot, "t" text, "p" points or "n" none. |
pord |
The result of a plot.polar.ord command i.e. a polar ordination plot result. |
labels |
A vector of labels to use for the sites. |
... |
Other plotting commands to pass to plot or identify . |
Examples
See examples in the Custom R Commands page.
Get the file
You can get a copy of the .R file here. Click the link to open the text. Right-click and “Save As” to download the file.
Use the file
The routines are in the main data file. However, if you get the Polar Ordination.R file separately, it opens in any text editor. To install the commands in R, use something like:
source(file.choose())
Then select the file. In Linux you’ll need to specify the filename explicitly.
February 2015
Modified command:
plot_H()
This formerly computed bootstrap confidence intervals only (for “shannon” or “simpson”). Now you can specify "shannon"
, "simpson"
, or "invsimpson"
, which use H_CI()
and methods using variance estimates. The command calculates the appropriate diversity index and CI, then plots the result.
NOTE: returns an error if you specify boot = TRUE
and index = "invsimpson"
.
New command:
Iapp()
This compliments the functions Happ()
and Dapp()
. It calculates bootstrap CI for Inverse Simpson’s index ("invsimpson"
). Designed for use with apply()
and others as an “internal” command.
New command:
aic()
This is a wrapper for add1()
that allows display of potential variables in order of AIC. You can specify order (default: decreasing = FALSE
) and number of “results” to display. Specify n = "all"
to show all results (the default), or integer to display n results. This is useful when your pool of potential variables (the scope
parameter) is large.
Imported & modified commands from vegan 1.17.12:
Some changes in recent versions of the vegan R-package prompted a few alterations.
Fisher's log series:
The vegan
team removed Std Err calculations from fisherfit()
. There are sensible reasons for doing so as CI are somewhat “dodgy”. However, to get the same results as the exercises in the book I restored the behaviours. If you want to get the same output as the book then use fisher_alpha()
and fisher_fit()
in place of fisher.alpha()
and fisherfit()
commands.
fisher_alpha()
Renamed from fisher.aplha()
and restores calculation of se and allows profiling.
fisher_fit()
Renamed from fisherfit()
, which allows se calculations and profiling using the following commands restored from vegan 1.17.12.
confint.fisherfit() plot.profile.fisherfit() profile.fisherfit()
My Publications
I have written several books on ecology and data analysis
Register your interest for our Training Courses
We run training courses in data management, visualisation and analysis using Excel and R: The Statistical Programming Environment. Courses will be held at one of our training centres in London. Alternatively we can come to you and provide the training at your workplace. Training Courses are also available via an online platform.
Get In Touch Now
for any information regarding our training courses, publications or help with a data project