gpt4 book ai didi

r - G * t(帽子) : non-conformable arrays 中的错误

转载 作者:行者123 更新时间:2023-12-01 23:32:41 29 4
gpt4 key购买 nike

尝试在 R 中使用 adonis 执行 PERMANOVA。添加到我的数据表和因子中,但是,我不断收到示例错误 - G * t(hat) 中的错误:不一致性数组

没有 N/A 数据,它可以使用现成的数据矩阵和我自己的数据表的子集。

无效的示例数据;

subset<-matrix(c(0,0.000666667,0.001333333,0.000333333,0.000333333,0.019833333,0.007666667,0.014666667,0.0005,0.022833333,0.016833333,0.018166667,0.000666667,0.009666667,0.008833333,0.009166667,0.001333333,0.018666667,0.0295,0.031833333),ncol=4)

test_groups<-c(1,1,2,2)
adonis(subset~test_groups)

Error in G * t(hat) : non-conformable arrays

测试数据是否有效;

test<-matrix(data=c(0.1,0.1,0.3,0.1,0.2,0.3,0.1,0,0.3,0.1,0.2,0.3,0.1,0.2,0.3,0.1),ncol=4)

为什么不起作用?

最佳答案

test_groups向量的长度为4,而subset的行数为5。
下面我将 subset 的行数设置为 5,并且 adonis 命令运行良好。

library(vegan) 
subset <- matrix(c(0,0.000666667,0.001333333,0.000333333,0.000333333,0.019833333,0.007666667,0.014666667,0.0005,0.022833333,0.016833333,0.018166667,0.000666667,0.009666667,0.008833333,0.009166667,0.001333333,0.018666667,0.0295,0.031833333),ncol=5)
test_groups <- c(1,1,2,2)
adonis(subset~test_groups)

这是结果。

'nperm' >= set of all permutations: complete enumeration.
Set of permutations < 'minperm'. Generating entire set.

Call:
adonis(formula = subset ~ test_groups)

Permutation: free
Number of permutations: 23

Terms added sequentially (first to last)

Df SumsOfSqs MeanSqs F.Model R2 Pr(>F)
test_groups 1 0.22804 0.22804 1.0592 0.34624 0.3333
Residuals 2 0.43059 0.21530 0.65376
Total 3 0.65864 1.00000

关于r - G * t(帽子) : non-conformable arrays 中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43736314/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com