获取pairwise.t.test的所有矩阵

时间:2019-04-18 18:16:09

标签: r pairwise

我想与pairwise.t.test进行所有比较,甚至与同一组进行比较以从软件包multcompLetter执行multcompview。因为(我认为),所以multcompLetters需要一个完整的矩阵,而不仅仅是比较矩阵的一半或一部分才能起作用。

dflong <- structure(list(moda = structure(c(4L, 4L, 4L, 4L, 4L, 1L, 1L, 
1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 
4L, 4L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 
3L, 4L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 
3L, 3L, 3L, 3L, 3L), .Label = c("HW1", "HW2", "HW3", "PG"), class = "factor"), 
    replicates = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 
    12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 1L, 2L, 3L, 
    4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 
    17L, 18L, 19L, 20L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 
    11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L), time = c("t0", 
    "t0", "t0", "t0", "t0", "t0", "t0", "t0", "t0", "t0", "t0", 
    "t0", "t0", "t0", "t0", "t0", "t0", "t0", "t0", "t0", "t14", 
    "t14", "t14", "t14", "t14", "t14", "t14", "t14", "t14", "t14", 
    "t14", "t14", "t14", "t14", "t14", "t14", "t14", "t14", "t14", 
    "t14", "t29", "t29", "t29", "t29", "t29", "t29", "t29", "t29", 
    "t29", "t29", "t29", "t29", "t29", "t29", "t29", "t29", "t29", 
    "t29", "t29", "t29"), unified = c(1096.6, 1304, 1205.2, 1278.9, 
    1221.3, 1090.7, 1022.7, 1071.3, 808.8, 1093.9, 1710.5, 1541.3, 
    1352.3, 1550.8, 1482.8, 1733.1, 1652.2, 1736.2, 1730.2, 1554, 
    263.7, 283, 302.3, 305.3, 288, 314.4, 369.3, 408.5, 408.5, 
    376.9, 295.9, 299.7, 304, 306.9, 309.3, 300.7, 300.6, 298.3, 
    302, 306, 6.68, 6.58, 6.63, 6.44, 6.55, 5.53, 4.56, 3.58, 
    3.84, 4.67, 6.57, 6.62, 6.62, 6.6, 6.62, 6.69, 6.86, 6.99, 
    6.95, 6.81)), row.names = c(NA, -60L), class = "data.frame")

yy <-dflong$unified
xx <-dflong$time
pair <- function(x) {hhg <- pairwise.t.test(yy,xx,data=x, p.adj = "bonf") }
o <-by(dflong$unified, dflong$moda, FUN=pair )

library(multcompView)
Warning message:
package ‘multcompView’ was built under R version 3.5.3 
q <- multcompLetters(o$HW1$p.value, threshold = 0.05)
q
t14 t29 
"a" "b" 

带有multcompLetters的最终输出必须类似于以下内容(只是我未验证的示例):

t0 t14 t29
"a" "b" "ab"

但是我总是得到这个

t14 t29
"b" "ab"

因此,让我们采用pairwise.t.test的结果之一

u <- o$HW1$p.value
u
              t0          t14
t14 4.917055e-27           NA
t29 7.395561e-33 4.756832e-07

我想要这样的(虚幻示例):

             t0          t14          t29
t0            NA 4.917055e-27  7.395561e-33
t14 4.917055e-27           NA  4.756832e-07
t29 7.395561e-33 4.756832e-07          NA

如果我可以将NA替换为1,我想对于multcompLetter甚至更好。

0 个答案:

没有答案