kruskal_test {rstatix} | R Documentation |
Provides a pipe-friendly framework to perform Kruskal-Wallis
rank sum test. Wrapper around the function
kruskal.test()
.
kruskal_test(data, formula, ...)
data |
a data.frame containing the variables in the formula. |
formula |
a formula of the form |
... |
other arguments to be passed to the function
|
return a data frame with the following columns:
.y.
: the y variable used in the test.
n
: sample count.
statistic
: the kruskal-wallis rank sum statistic used to
compute the p-value.
p
: p-value.
method
: the
statistical test used to compare groups.
# Load data
#:::::::::::::::::::::::::::::::::::::::
data("ToothGrowth")
df <- ToothGrowth
# Kruskal-wallis rank sum test
#:::::::::::::::::::::::::::::::::::::::::
df %>% kruskal_test(len ~ dose)
# Grouped data
df %>%
group_by(supp) %>%
kruskal_test(len ~ dose)