vegan
is one of the packages which features in day to
day working of a community ecologist. It would be great to know a few
cases where the package comes in handy.
To begin with we can load some inbuilt data, BCI.
data("BCI")
Seems there is a lot of data here, we can check the dimensions of the
dataframe using the dim
finction from base R
package.
dim(BCI)
## [1] 50 225
So, this is a data set of 50 sampling plots indicating number of individuals of species of trees counted in each plot. Typical ecological survey work in community ecology.
So, we can go ahead and calculate species diversity in the 50 plots using shannon index. There are also indices like simpson or invsimpson that one can calculate from the data.
We can do for all of them:
diversity(BCI, index = 'shannon') # This calculates an index for each plot, so 50 indices
## 1 2 3 4 5 6 7 8
## 4.018412 3.848471 3.814060 3.976563 3.969940 3.776575 3.836811 3.908381
## 9 10 11 12 13 14 15 16
## 3.761331 3.889803 3.859814 3.698414 3.982373 4.017494 3.956635 3.916821
## 17 18 19 20 21 22 23 24
## 3.736897 3.944985 4.013094 4.077327 3.969925 3.755413 4.062575 3.979427
## 25 26 27 28 29 30 31 32
## 4.074718 3.947749 3.980281 3.693896 3.688721 3.851598 3.724967 3.784873
## 33 34 35 36 37 38 39 40
## 3.740392 3.821669 2.641859 3.846109 3.791703 3.516082 3.530494 3.234849
## 41 42 43 44 45 46 47 48
## 4.052495 3.966614 3.736254 3.705016 3.609518 3.810489 3.920918 3.913725
## 49 50
## 3.778851 3.906616
diversity(BCI, index = 'simpson')
## 1 2 3 4 5 6 7 8
## 0.9746293 0.9683393 0.9646078 0.9716117 0.9678267 0.9627557 0.9672014 0.9671998
## 9 10 11 12 13 14 15 16
## 0.9534257 0.9663808 0.9658398 0.9550599 0.9692075 0.9718626 0.9709057 0.9686598
## 17 18 19 20 21 22 23 24
## 0.9545126 0.9676685 0.9655820 0.9748589 0.9686058 0.9548316 0.9723529 0.9694268
## 25 26 27 28 29 30 31 32
## 0.9726152 0.9709567 0.9669962 0.9499296 0.9481041 0.9602659 0.9635807 0.9565267
## 33 34 35 36 37 38 39 40
## 0.9586946 0.9607876 0.7983976 0.9648567 0.9565015 0.9365144 0.9360204 0.9137131
## 41 42 43 44 45 46 47 48
## 0.9731442 0.9731849 0.9569632 0.9578733 0.9528853 0.9646728 0.9672083 0.9676412
## 49 50
## 0.9609552 0.9679784
diversity(BCI, index = 'invsimpson')
## 1 2 3 4 5 6 7 8
## 39.415554 31.584877 28.254778 35.225771 31.081658 26.849731 30.489077 30.487609
## 9 10 11 12 13 14 15 16
## 21.471056 29.744868 29.273803 22.251827 32.475442 35.539830 34.371014 31.907937
## 17 18 19 20 21 22 23 24
## 21.984098 30.929617 29.054548 39.775448 31.853042 22.139382 36.170213 32.708387
## 25 26 27 28 29 30 31 32
## 36.516636 34.431303 30.299530 19.971863 19.269343 25.167317 27.457940 23.002620
## 33 34 35 36 37 38 39 40
## 24.209883 25.502106 4.960258 28.454909 22.989309 15.751596 15.629977 11.589250
## 41 42 43 44 45 46 47 48
## 37.235945 37.292428 23.235938 23.737903 21.224806 28.306797 30.495526 30.903463
## 49 50
## 25.611603 31.228916
The indices are quite related to each other as indicated in the following plots.
Relationship between shannon and simpson indices of diversity.
plot(diversity(BCI, index = 'shannon'), diversity(BCI, index = 'simpson'))
Relationship between shannon and invsimpson indices of diversity.
plot(diversity(BCI, index = 'shannon'), diversity(BCI, index = 'invsimpson'))
Relationship between simpson and invsimpson indices of diversity.
plot(diversity(BCI, index = 'simpson'), diversity(BCI, index = 'invsimpson')) # curvilinear relationship
We can also calculate fisher.alpha for the dataset using the function
fisher.alpha()
.
fisher.alpha(BCI)
## 1 2 3 4 5 6 7 8
## 35.67297 30.99091 33.32033 33.92209 37.96423 32.49374 30.58383 33.44981
## 9 10 11 12 13 14 15 16
## 35.67236 34.82320 34.20590 34.12041 37.56974 39.21837 35.07926 36.16927
## 17 18 19 20 21 22 23 24
## 39.21057 38.71442 46.85170 40.99634 41.58728 35.84847 46.92764 39.87658
## 25 26 27 28 29 30 31 32
## 43.53983 36.40222 41.03649 33.65451 35.54363 36.87417 27.62298 32.34465
## 33 34 35 36 37 38 39 40
## 32.08718 35.12348 26.11065 35.88775 33.28235 29.46136 31.41425 27.17138
## 41 42 43 44 45 46 47 48
## 44.06386 33.59822 33.31374 30.28666 29.02041 32.32598 42.56011 35.99618
## 49 50
## 35.41942 36.40426
Further, we can plot species accumulation curve for the dataset. This is showing how the number of species vary wiith number of plots sampled. Normally the curve flattens at some point in which case additional sampling does not yield any more new species.
plot(specaccum(BCI))
## Warning in cor(x > 0): the standard deviation is zero
Lastly, for now, we can check for detrended correspondence analysis
plot using decorana()
function.
plot(decorana(BCI))