wilcox.test获取所有信息测试

时间:2017-03-27 21:27:51

标签: r

df <- read.table(header=TRUE, text='
  presence Var3 Var1 Var2
                              N     7.9  12.3  10.7
                              N     6.3  10.6  11.1
                              N     9.5  13.1  13.8
                              Y    33.2  13.4  12.9
                              Y     6.3  11.6  11.1
                              Y    14.5  13.8  12.9
                           ')

我为数据帧的多个列运行wilcox.test

 test_pw<- lapply(2:4, function(x) pairwise.wilcox.test(df[[x]], df$presence, mu=0))

我只能看到pvalue,但是我希望获得有关测试的更多信息,例如V(W)

    Pairwise comparisons using Wilcoxon rank sum test 

data:  df[[x]] and df$presence 

  H   
N 0.31

P value adjustment method: holm 

类似的东西

Wilcoxon signed rank test

data:  df$Var1 by df$presence
V = 21, p-value = 0.03125
alternative hypothesis: true location shift is not equal to 0

当我跑

lapply(test_pw, summary)

我得到每个变量:

[[3]]
                Length Class  Mode     
method          1      -none- character
data.name       1      -none- character
p.value         1      -none- numeric  
p.adjust.method 1      -none- character

1 个答案:

答案 0 :(得分:1)

我认为只需在函数中添加summary()即可。

test_pw<- lapply(3:5, function(x) summary(pairwise.wilcox.test(df[[x]], df$presence, mu=0)))