【问题标题】:How do I enter environmental variables only as a factor (not as continuous variables) in the capscale function?如何在 capscale 函数中仅将环境变量作为一个因子(而不是连续变量)输入?
【发布时间】:2015-09-03 14:30:33
【问题描述】:

我正在对物种丰度表执行 CAP 分析(素食主义者,R),其中包含 2 个解释因素(Location 和 Complexity_Watson)和一个解释连续变量(Depth..m.)。 下面你会发现我的一些代码:

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

但是,summary(species.cap) 将位置和复杂性作为约束(连续)变量和约束因素。

我怎样才能确保它只将它们作为因素输入? (我尝试添加factor(),但结果相同)。

当我想绘制环境变量时,它会为位置和复杂性创建箭头和质心,而我只想要质心(以及深度的箭头)。

有人可以帮我吗?

【问题讨论】:

    标签: r vector factors vegan cap


    【解决方案1】:

    使用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)
    

    对于绘图问题,您必须意识到plot 正在调用plot.cca。使用plot.cca 中的帮助部分来确定您的问题的解决方案。

    我想你想要的是:

    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
    

    此外,vegan tutorial 是一个很好的参考,其中包含有用的示例。

    【讨论】:

    • 当前的 vegan 版本 (2.3-0) 确实要求您的因素是严格因素,而不仅仅是看起来像因素的字符串。这将在下一个版本 (2.3-1) 中发生变化,该版本还为未正式定义为因子的字符变量找到质心。这涉及约束排序的所有功能(capscale,rda,cca)
    猜你喜欢
    • 1970-01-01
    • 2019-07-30
    • 1970-01-01
    • 2014-01-23
    • 1970-01-01
    • 1970-01-01
    • 2018-12-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多