Difference between Wilcoxon test and Pairwise Wilcoxon test in R? I am trying to understand what the difference is between wilcox.test and pairwise.wilcox.test. When we have two variables the output of both functions is the same. Here is some reproducible code:
set.seed(7)
df <- data.frame(V1 = runif(100),
                 V2 = runif(100))
wilcox.test(df$V1, df$V2)
#> 
#>  Wilcoxon rank sum test with continuity correction
#> 
#> data:  df$V1 and df$V2
#> W = 4601, p-value = 0.3302
#> alternative hypothesis: true location shift is not equal to 0
pairwise.wilcox.test(t(df), g = seq(1,2))
#> 
#>  Pairwise comparisons using Wilcoxon rank sum test with continuity correction 
#> 
#> data:  t(df) and seq(1, 2) 
#> 
#>   1   
#> 2 0.33
#> 
#> P value adjustment method: holm

As you can see both have the same p-value. But when we add an extra feature while still comparing V1 and V2, the output is different:
set.seed(7)
df <- data.frame(V1 = runif(100),
                 V2 = runif(100),
                 V3 = runif(100))
wilcox.test(df$V1, df$V2)
#> 
#>  Wilcoxon rank sum test with continuity correction
#> 
#> data:  df$V1 and df$V2
#> W = 4601, p-value = 0.3302
#> alternative hypothesis: true location shift is not equal to 0
pairwise.wilcox.test(t(df), g = seq(1,3))
#> 
#>  Pairwise comparisons using Wilcoxon rank sum test with continuity correction 
#> 
#> data:  t(df) and seq(1, 3) 
#> 
#>   1    2   
#> 2 0.99 -   
#> 3 0.99 0.99
#> 
#> P value adjustment method: holm

Why is the output of the pairwise.wilcox.test for V1 and V2 now different? Although it is the same comparison right?

Because by default pairwise.wilcox.test() performs a correction for multiple testing.
See help(pairwise.wilcox.test).
You can turn it off:
pairwise.wilcox.test(t(df), g = 1:3, p.adjust.method = "none")

And then the results will match:
Pairwise comparisons using Wilcoxon rank sum test with continuity correction 

data:  t(df) and 1:3

  a    b   
b 0.33 -   
c 0.85 0.42

P value adjustment method: none

As you can see the hint was there all along: last line, reporting the p-value adjustment method.
