Get all matrix of pairwise.t.test

最后都变了- 提交于 2019-12-25 02:09:26

问题


I would like to get all comparison with pairwise.t.test even comparison with the same group to perform multcompLetterfrom the packagemultcompview. Because (I think), multcompLetters needs a full matrix and not only the half or a part of the comparison matrix to work.

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" 

The final output with multcompLetters has to be like something like this (just an example I didn't verify):

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

But I always get this

t14 t29
"b" "ab"

So let's take one of the result of pairwise.t.test

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

And what i would like like this (unreal example):

             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

And if i can replace NA by 1 it's even better for multcompLetter i guess.

来源:https://stackoverflow.com/questions/55751713/get-all-matrix-of-pairwise-t-test

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!