&引用;尺寸数量不正确“;在R中建立索引时出错

&引用;尺寸数量不正确“;在R中建立索引时出错,r,indexing,statistics,R,Indexing,Statistics,我第二次分析论文的一些结果,因为我有了新的数据,我使用了dunntest()函数,得到了如下表: Comparison Z P.unadj P.adj 1 D20FN30K - D20FN60K -1.7340246 8.291372e-02 1.160792e-01 2 D20FN30K - D20MG30K 1.3602563 1.737488e-01 2.211349e-01 3 D20FN60K - D20MG30K 3.0942809

我第二次分析论文的一些结果,因为我有了新的数据,我使用了dunntest()函数,得到了如下表:

Comparison          Z      P.unadj        P.adj
1  D20FN30K - D20FN60K -1.7340246 8.291372e-02 1.160792e-01
2  D20FN30K - D20MG30K  1.3602563 1.737488e-01 2.211349e-01
3  D20FN60K - D20MG30K  3.0942809 1.972906e-03 3.068965e-03
然而,当我试图通过键入PT[,4]将其索引为只有p值时,它会给出一个错误,即“维数不正确”。
我使用的代码与第一次工作时使用的代码相同,但现在突然不起作用。

我尝试使用FSA软件包中的dunntest函数执行dunntest,我认为问题在于,函数的输出不是数据帧或矩阵

您需要从输出中提取结果数据帧

以下是为测试模拟的数据:(来自)

为了提取p值,我做了以下操作:

a =dunnTest(ponds2$pH,ponds2$pond)
a = a$res
a$P.adj

我希望它能有所帮助

您能否将
dput(PT)
的输出包括在内(假设它与上面一样,只包含几行)?这可能有助于解释为什么会发生这种情况(我怀疑它实际上是一个
列表
,所以
[,4]
矩阵式索引将不起作用)。此外,我找不到
dunntest
。我可以找到
dunn.test::dunn.test
FSA::dunnTest
,以及
DescTools::dunnTest
;你用哪一种?
    > dunnTest(ponds2$pH,ponds2$pond)
Dunn (1964) Kruskal-Wallis multiple comparison
  p-values adjusted with the Holm method.

  Comparison           Z     P.unadj      P.adj
1      1 - 2 -2.13700630 0.032597479 0.13038992
2      1 - 3 -2.94934889 0.003184443 0.01592221
3      2 - 3 -0.88480467 0.376261991 1.00000000
4      1 - 4 -2.99180882 0.002773299 0.01663979
5      2 - 4 -0.85480252 0.392660483 0.78532097
6      3 - 4  0.05898698 0.952962480 0.95296248
a =dunnTest(ponds2$pH,ponds2$pond)
a = a$res
a$P.adj