R function for visually displaying Kruskal-Wallis test's results

The function allows allows to perform Kruskal-Wallis test, and to display the test's results in a plot along with boxplots.

kwPlot(x, y, strip = FALSE, notch = FALSE, omm = FALSE,
  outl = TRUE, posthoc = FALSE, adjust = "bonferroni")

Object storing the values to be analysed.


Object storing a grouping variable with 3 or more levels.


Logical value which takes FALSE (by default) or TRUE if the user wants jittered points to represent individual values.


Logical value which takes FALSE (by default) or TRUE if user does not or do want to have notched boxplots in the final display, respectively; it is worth noting that overlapping of notches indicates a not significant difference at about 95 percent confidence.


It stands for overall mean and median; takes FALSE (by default) or TRUE if user wants the mean and median of the overall sample plotted in the chart (as a dashed RED line and dotted BLUE line respectively).


Logical value which takes FALSE or TRUE (by default) if users want the boxplots to display outlying values.


Logical value which takes FALSE (default) or TRUE if user does not or does want to perform a follow-up test (namely, the Dunn's test) in order to locate which group significantly differs from the others.


Sets the desidered method for p-values adjustment in the context of the Dunn's test; the list of methods is the following: Bonferroni ("bonferroni"; default); Holm ("holm"), Hochberg ("hochberg"), Hommel ("hommel"), Benjamini & Hochberg ("BH" or its alias "fdr"), Benjamini & Yekutieli ("BY"), none ("none"). For more info, see the 'p.adjust' help documentation in R (?p.adjust).


The boxplots display the distribution of the values of the two samples, and jittered points represent the individual observations. At the bottom of the chart, the test statistics (H) is reported, along with the degrees of freedom and the associated p value. Setting the parameter 'posthoc' to TRUE, the Dunn's test is performed (with Bonferroni adjustment by default): a dot chart is returned, as well as a list of p-values (2-sided). In the dot chart, a RED line indicates the 0.05 threshold. The groups compared on a pairwise basis are indicated on the left-hand side of the chart.

See Also


  • kwPlot
#create a toy dataset
mydata <- data.frame(values=c(rnorm(30, 100,10),rnorm(30, 80,10),rnorm(30, 98,10)),
group=c(rep("A", 30),rep("B", 30),rep("C", 30)))

# performs the test, displays the test's result, including jittered points and notches.
# It also performs the Dunn's posthoc test using Bonferroni p-value correction.
kwPlot(x=mydata$values, y=mydata$group, strip=TRUE, notch=TRUE, posthoc=TRUE)

# }
Documentation reproduced from package GmAMisc, version 1.0.0, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.