Does the pairwise_wilcox_test()
function from the rstatix package (https://rpkgs.datanovia.com/rstatix/reference/wilcox_test.html) provide your expected outcome?
I.e. using Damian Oswald's example:
library(tidyverse)
library(rstatix)
attach(airquality)
Month <- factor(Month, labels = month.abb[5:9])
test <- pairwise_wilcox_test(data = airquality,
formula = Ozone ~ Month)
test
#> # A tibble: 10 × 9
#> .y. group1 group2 n1 n2 statistic p p.adj p.adj.signif
#> * <chr> <chr> <chr> <int> <int> <dbl> <dbl> <dbl> <chr>
#> 1 Ozone 5 6 26 9 82 0.193 0.579 ns
#> 2 Ozone 5 7 26 26 110. 0.00003 0.0003 ***
#> 3 Ozone 5 8 26 26 128. 0.000121 0.001 **
#> 4 Ozone 5 9 26 29 284 0.119 0.476 ns
#> 5 Ozone 6 7 9 26 51.5 0.014 0.085 ns
#> 6 Ozone 6 8 9 26 57.5 0.026 0.13 ns
#> 7 Ozone 6 9 9 29 132. 0.959 1 ns
#> 8 Ozone 7 8 26 26 348 0.862 1 ns
#> 9 Ozone 7 9 26 29 578. 0.000744 0.006 **
#> 10 Ozone 8 9 26 29 552 0.003 0.023 *
# I think the "statistic" column is what you're after
test$statistic
#> W W W W W W W W W W
#> 82.0 109.5 127.5 284.0 51.5 57.5 132.5 348.0 577.5 552.0
Created on 2022-12-20 with reprex v2.0.2