rspear released on CRAN!
rspear was developed for the Department System Ecotoxicology of the Helmholtz Centre for Environmental Research a R package to calculate SPEAR (Liess & Von Der Ohe, 2005; Liess et. al. 2008).
The package is an interface to their web-application. It retrieves trait-data from their server and calculates from this SPEAR. Now you can perform all calculations/plots directly in R - no need to go to the webpage, upload data and download results and load them into R.
rspear is now available on CRAN, so installation is as simple as:
I added some example data to the package which I will use for demonstration:
So the data has for columns ‘Taxon’ (holding the species names), ‘Abundance’ (holding the abundances), ‘Year’ and ‘Site’ (which are two grouping variables). As you can see the data is in the log format and rspear requires long data (as the web-application). If you have your data in the wide format you can use melt() from the reshape2-package.
We want to calculate SPEAR-values per year and site. The main function of rspear is spear():
The first argument is our data (‘spear_example’), and afterwards we must specify the columns holding the taxon names, the abundances and grouping variables. These must match the column names of the data, otherwise the function stops with an error.
The warnings tell us that not all taxa could be matches directly with the trait-database. rspear tries to guess which taxon matches, however you should always check! For taxon ‘xxxxxxxxx’ rspear was not able to make a good guess and the SPEAR-value for this species was set to 0.
Let’s look at our results: rspear returns a list with two entries: ‘spear’ and ‘traits’.
First we check the matched species, since we got a warning. We look a the trait-table for this:
Looking at the
we see that there has been no match (match_val == NA) for taxon ‘xxxxxxxxx’ and ‘Baetis rodani’ has been matched approximately (match_val = 0.1) with ‘Baetis rhodani’. The value in match_val indicates how good the guess for the species is.
All other taxa have been matched directly (match_val = -1). The SPEAR-value for ‘xxxxxxxx’ has been set to ‘0’. We could check and clean our input data, but the matches are appropriate in this case.
Now let’s look at the spear values:
These results can be directly used for further analysis (plotting, hypothesis testing, etc):
You can also change the thresholds (not recommended) or change the SPEAR-values of individual species. Please read the vignette for further information.
Liess M and Von Der Ohe P (2005). “Analyzing Effects of Pesticides on Invertebrate Communities in Streams.” Environmental Toxicology And Chemistry, 24. ISSN 0730-7268, http://dx.doi.org/10.1897/03-652.1.
Liess M, Schäfer RB and Schriever CA (2008). “The Footprint of Pesticide Stress in Communities—Species Traits Reveal Community Effects of Toxicants.” Science of The Total Environment, 406. ISSN 00489697, http://dx.doi.org/10.1016/j.scitotenv.2008.05.054.