首页 > 解决方案 > ANOSIM Error Vegan Package R - “if (xi > xj) 1L else -1L 中的错误:需要 TRUE/FALSE 的地方缺少值”

问题描述

我正在尝试使用两个分组变量完成物种存在数据的 ANOSIM 这是数据框的示例(原始数据框有 50 列):

print(rec.ano.wide[1:5])
# Groups:   cyclone_time [2]
  cyclone_time  acanthastrea acropora astreopora blastomussa
  <fct>               <dbl>    <dbl>      <dbl>       <dbl>
1 before                 15      119         21           3
2 after                  10      154          6           1

我使用以下代码执行 anosim 分析:

#get the grouping variable
group <- rec.ano.wide[, "cyclone_time"]

#create community matrix
rec.com <- rec.ano.wide[,2:ncol(rec.ano.wide)]
rec.matrix = as.matrix(rec.com)

#anosim analysis
rec.ano = anosim(rec.matrix, group, distance = "bray", permutations = 9999)

该分析给出了这个错误

Error in if (xi > xj) 1L else -1L : missing value where TRUE/FALSE needed
In addition: Warning message:
In Ops.factor(xi, xj) : ‘&gt;’ not meaningful for factors

我不知道这意味着什么,所以任何帮助将不胜感激!!

标签: rstatisticsvegan

解决方案


推荐阅读