Shuffles the combined samples n_permutations times to
construct the null distribution of the chosen test statistic.
coin's coin::oneway_test(distribution = "approximate")
implements the same test with a Monte-Carlo null; it is delegated
to when coin is installed and statistic is the
default "mean_diff" (the rmorie API allows arbitrary
f(g1, g2) which coin does not expose, so a custom statistic
falls back to the inline shuffle loop). The inline path keeps the
full null distribution which downstream MRM code consumes.
Usage
permutation_test(
group1,
group2,
statistic = "mean_diff",
n_permutations = 9999L,
alternative = "two-sided",
seed = 42L
)