Reputation: 1814
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
Upvotes: 1
Views: 269
Reputation: 1237
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)))
Upvotes: 1