1

我想从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

有什么简单的方法吗?

干杯!

4

1 回答 1

2

你可以用这个

temp <-pairwise.wilcox.test(df$vars, df$obs)$p.value
df <- data.frame(expand.grid(dimnames(temp)),array(temp))
na.omit(df)
于 2012-08-03T11:00:26.667 回答