使用orditorp:下标超出界限时出错

时间:2017-11-25 03:58:01

标签: r

我对R很陌生,我试图在CCA情节中展示物种名称。我发现你可以在创建一个空白的CCA图之后使用orditorp来用截断的物种名称替换默认点。但是,当我尝试运行orditorp函数时,我收到错误消息:

Error in x[ord, ] : subscript out of bounds
In addition: Warning messages:
1: In x[, 1] - w :
  longer object length is not a multiple of shorter object length
2: In x[, 1] + w :
  longer object length is not a multiple of shorter object length
3: In x[, 2] - h :
  longer object length is not a multiple of shorter object length
4: In x[, 2] + h :
  longer object length is not a multiple of shorter object length

我正在运行的代码如下:

bmi_all<- read.delim("BMI_data_all_var.txt", header=T, sep="\t", row.names=1)
library(vegan)
taxa.matrix <- subset(bmi_all, select=Chironomidae:Neoporus)
attach(bmi_all)
#perform a correspondance analysis on my bmi data
bmi_ca<- cca(taxa.matrix~TSS+BChla+SChla+DSub, na.action=na.exclude)
cnam<-make.cepnames(names(taxa.matrix))
stems<-colSums(taxa.matrix)
plot(bmi_ca, dis="sp", type="n")
orditorp(bmi_ca,"sp",label=cnam,priority=stems,pch="+",pcol="red")

如果我跑plot(bmi_ca, dis="sp", type="t")我得到了CCA情节,但正如预期的那样,物种名称会产生非常混乱的排序。在创建taxa.matrixbmi_ca时,我已尝试将cnam替换为stems,但在尝试应用orditorp时出现同样的错误。< / p>

有什么想法吗?

提前致谢!

-Jordan

1 个答案:

答案 0 :(得分:0)

经过一番摆弄,我设法解决了我的问题!我从我的数据集中删除了一个站点,这导致一些物种的丰度为零。删除它们并运行代码后,它就可以了!