简体   繁体   English

如何仅在capscale函数中输入环境变量作为因子(而不是连续变量)?

[英]How do I enter environmental variables only as a factor (not as continuous variables) in the capscale function?

I am performing a CAP analysis (vegan, R) on a species abundance table, with 2 explaining factors (Location and Complexity_Watson) and one explaining continuous variable (Depth..m.). 我在物种丰富度表上执行CAP分析(素食主义者,R),有2个解释因子(Location和Complexity_Watson)和一个解释连续变量(Depth..m。)。 Below you will find some of my code: 您将在下面找到我的一些代码:

species.cap=capscale(Species.MVA.DOV ~ Location + Depth..m. + 
   Complexity_Watson, data=Habitat.MVA.DOV, distance="bray", na.action=na.omit)

However, summary(species.cap) yields the location & complexity as both constraining (continuous) variables and constraining factors. 然而, summary(species.cap)产生的位置和复杂性都是约束(连续)变量和约束因子。

How can I make sure it only enters them as factors? 我怎样才能确保它只作为因素输入? (I tried adding factor() but that yielded the same result). (我尝试添加factor()但产生了相同的结果)。

When I want to plot the environmental variables, it creates both arrows and centroids for location and complexity, while I only want centroids (and an arrow for depth). 当我想绘制环境变量时,它会为位置和复杂性创建箭头和质心,而我只需要质心(以及深度箭头)。

Could someone help me out? 有人可以帮帮我吗?

Use as.factor to change the variables to factors in the dataframe Habitat.MVA.DOV 使用as.factor将变量更改为数据Habitat.MVA.DOV因子

Habitat.MVA.DOV$Location <- as.factor(Habitat.MVA.DOV$Location)
Habitat.MVA.DOV$Complexity_Watson <- as.factor(Habitat.MVA.DOV$Complexity_Watson)

For the plotting question you have to realize that plot is calling plot.cca . 对于绘图问题,你必须意识到plot是调用plot.cca Use the help section in plot.cca to pinpoint the solution to your question. 使用plot.cca的帮助部分来查明问题的解决方案。

I think what you want is: 我想你想要的是:

plot(species.cap, display = "cn") #cn stands for centroid, see help for other options
?plot.cca # gets you to the documentation/help on plot.cca

Also, the vegan tutorial is a great reference with helpful examples. 此外, 素食教程是一个很好的参考,有用的例子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM