I am using ggpubr
currently to plot my values. Thanks to the facets I managed to create subplots according to some factor. Finally, using the function stat_compare_means()
I managed to plot only the differences between groups.
The minimal code to produce my figures is
library(ggpubr)
data("ToothGrowth")
my_comparisons <- list( c("0.5", "1"), c("1", "2"), c("0.5", "2") )
p <- ggboxplot(ToothGrowth, x = "dose", y = "len",
color = "supp", palette = "npg",
add = "jitter",
facet.by = "supp", short.panel.labs = FALSE)
p + stat_compare_means(comparisons = my_comparisons, label = "p.signif")
where supp
is the grouping factor, len
the outcome and dose
the independent variable.
This is the result:
I would like to display also differences within groups (e.g. statistical significance between 0.5|OJ and 0.5|VC), but I think it is not possible with my current code.
Could someone please point me towards some example on how to achieve what I want?