1
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
                           ')

I run a wilcox.test for multiple column of a dataframe

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

I can only see the pvalue, however I would like to get more info regarding the test such as V (W)

    Pairwise comparisons using Wilcoxon rank sum test 

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

  H   
N 0.31

P value adjustment method: holm 

something like that

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

when I run

lapply(test_pw, summary)

I get for each variable this:

[[3]]
                Length Class  Mode     
method          1      -none- character
data.name       1      -none- character
p.value         1      -none- numeric  
p.adjust.method 1      -none- character
Al14
  • 1,734
  • 6
  • 32
  • 55
  • 2
    It's easier to help you if you provide a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input data so we can run the code. Seems like all your values are probably in that list. Maybe `lapply(test_pw, summary)` is what you are after? It's not clear to me what the desired output is. – MrFlick Mar 27 '17 at 21:30
  • summary does not work – Al14 Mar 27 '17 at 21:46
  • 1
    What does "does not work" mean exactly? – MrFlick Mar 27 '17 at 21:46
  • 1
    `pairwise.wilcox.test` doesnt return these. However, it call `wilcox.text` within it, and this does, so should be easy enough to write another that tweaks the function to return what you want. – user20650 Mar 28 '17 at 03:00

1 Answers1

1

I think simply adding summary() inside your function should work.

test_pw<- lapply(3:5, function(x) summary(pairwise.wilcox.test(df[[x]], df$presence, mu=0)))
Julian Wittische
  • 1,219
  • 14
  • 22