Add significance letters to boxplots

ggplot2

#1

Hi.
I am new to R, and need a little help :slight_smile:
I have run a dunn's test on my 5 variables, and also made boxplots. I want to add significant letters over my boxplots to show significance, but are not sure how to do that!
I kind of want it to look like the boxplot below.
Anybody able to help me out?


#2

Those letters are called "compact letter display", which may help on any internet searches. :slightly_smiling_face:

I have used package emmeans for doing post-hoc tests and calculating compact letter display via the cld() function. I've then taken those results and added them to plots. I'm sure other packages can create the compact letter display, as well; it may depend on what type model you fit and what package you used for the post-hoc tests.

As an aside, I am definitely pro-boxplot but when I am showing results from a statistical analysis involving means I add the means to the plot in addition to the median line so the analysis and results "match" better.


#3

Hey Morild,

I got the same problem. I read that de cld() is only applicable when your data set has been run in a tuckeyhsd test. If i am correct, we have to use cldlist() from the rcompanion package. But i got trouble installing it. Did you mybe figured out how to do it otherwise?

Kind regards,

Jutka Yik


#4

Another package you might want to take a look at is ggstatsplot


I haven't used it much, but it has a lot of tools for adding coefficients, etc. to various types of plots
https://indrajeetpatil.github.io/ggstatsplot/articles/ggbetweenstats.html
https://indrajeetpatil.github.io/ggstatsplot/articles/ggcoefstats.html


#5

Thanks, Mara! :blush: