vegan介绍与入门
vegan是一个用于群落生态学(community ecology)分析的包,可以进行排序、多样性和差异性分析(ordination, diversity and dissimilarity)。
vegan包含了多样性分析、排序方法和差异性分析的工具。
示例一:unconstrained analysis(非约束排序)
### example1: unconstrained analysis
## NMDS
library(vegan)
data(varespec)
data("varechem")
ord = metaMDS(varespec)
plot(ord, type = "t")
# fit environmental variables
ef = envfit(ord, varechem)
ef
plot(ef, p.max = 0.05)
> ef
***VECTORS
NMDS1 NMDS2 r2 Pr(>r)
N -0.05729 -0.99836 0.2536 0.035 *
P 0.61969 0.78484 0.1938 0.108
K 0.76642 0.64234 0.1809 0.109
Ca 0.68517 0.72838 0.4119 0.004 **
Mg 0.63250 0.77456 0.4270 0.002 **
S 0.19135 0.98152 0.1752 0.119
Al -0.87162 0.49019 0.5269 0.001 ***
Fe -0.93604 0.35190 0.4450 0.002 **
Mn 0.79872 -0.60171 0.5231 0.001 ***
Zn 0.61754 0.78654 0.1879 0.109
Mo -0.90308 0.42948 0.0609 0.526
Baresoil 0.92491 -0.38019 0.2508 0.045 *
Humdepth 0.93284 -0.36029 0.5200 0.001 ***
pH -0.64800 0.76164 0.2308 0.061 .
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Permutation: free
Number of permutations: 999
示例二:constrainted analysis(约束排序)
### example2: constrained ordination (RDA)
## the example uses formula interface to define the modle
library(vegan)
data("dune")
data("dune.env")
# no constraints: PCA
mod0 = rda(dune ~ 1, dune.env)
mod0
plot(mod0)
# all environmental variables: Full model
mod1 = rda(dune ~ ., dune.env)
mod1
plot(mod1