我想从pairwise.wilcox.test:
转换输出矩阵> df <- data.frame(obs = c(rep("a", 10), rep("b", 10), rep("c", 10), rep("d", 10)),
vars = c(runif(10, 1, 3), runif(10, 1, 6), runif(10, 3, 7), runif(10, 2, 9)))
> pairwise.wilcox.test(df$vars, df$obs)$p.value
a b c
b 6.299985e-01 NA NA
c 6.495053e-05 0.02052437 NA
d 6.495053e-05 0.01554483 0.6299985
进入如下列表:
a b 6.299985e-01
a c 6.495053e-05
a d 6.495053e-05
b c 0.02052437
b d 0.01554483
c d 0.6299985
有没有简单的方法呢?
干杯!
答案 0 :(得分:1)
您可以使用此
temp <-pairwise.wilcox.test(df$vars, df$obs)$p.value
df <- data.frame(expand.grid(dimnames(temp)),array(temp))
na.omit(df)