我正在尝试将envfit箭头叠加到像这样的NMDS图表上(当我用假数字替换缺失值时):
但是,根据我们的实际数据,它不会给出箭头,而是单独标记每个点,如下所示:
任何建议都将不胜感激。
Code:
# Make MDS
x.mds <- metaMDS(x_matrix, trace = FALSE)
# Extract point co-ordinates for putting into ggplot
NMDS <- data.frame(MDS1 = x.mds$points[,1], MDS2 = x.mds$points[,2])
p <- ggplot(NMDS, aes(MDS1, MDS2))
p + geom_point()
#environmental variables
ef <- envfit(x.mds ~ pH + Ammonia + DO, x.env)
ef <- envfit(x.mds ~ pH + Ammonia + DO, x.env, na.rm = TRUE) ##ALTERNATIVE
plot(ef)
数据:
Sample Region pH Ammonia Nitrate BOD DO
15 N 7.618 0.042 0.845 1 NA
34 N 7.911 0.04 7.41 8 5.62
42 SE 7.75 NA 3.82 1 21.629
........
> ef
***VECTORS
NMDS1 NMDS2 r2 Pr(>r)
pH 0.50849 -0.86107 0.0565 0.719
Ammonia 0.99050 -0.13751 0.0998 0.504
DO -0.88859 -0.45871 0.1640 0.319
P values based on 999 permutations.
1 observation deleted due to missingness
> str(ef)
List of 3
$ vectors :List of 4
..$ arrows : num [1:3, 1:2] 0.508 0.991 -0.889 -0.861 -0.138 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:3] "pH" "Ammonia" "DO"
.. .. ..$ : chr [1:2] "NMDS1" "NMDS2"
.. ..- attr(*, "decostand")= chr "normalize"
..$ r : Named num [1:3] 0.0565 0.0998 0.164
.. ..- attr(*, "names")= chr [1:3] "pH" "Ammonia" "DO"
..$ permutations: num 999
..$ pvals : num [1:3] 0.719 0.504 0.319
..- attr(*, "class")= chr "vectorfit"
$ factors : NULL
$ na.action:Class 'omit' int 17
- attr(*, "class")= chr "envfit"