I have already named the values of the t.test scores in the plot by giving dimensions to my_comparisions
. Is there an alternate way to do this. Because, I am using this inside R shiny and hence there are lots of columns (similar to ColB) involved. So want to know if there is any other method
library(ggpubr)
library(ggplot2)
df <- structure(list(ColA = c(39, 13, 16, 36, 20, 18, 23, 21, 47, 46,
15, 11, 13, 36, 48, 18, 31, 32, 19, 39, 40, 41, 45, 38, 18, 38,
38), ColB = c("A", "A", "A", "A", "A", "A", "A", "A", "A", "B",
"B", "B", "B", "B", "B", "B", "C", "C", "C", "D", "D", "D", "D",
"D", "D", "D", "D")), row.names = c(NA, -27L), class = c("tbl_df",
"tbl", "data.frame"))
df <- as.data.frame(df)
my_comparisons <- list( c("A", "B"), c("A", "C"), c("A", "D"), c("B", "C"), c("B", "D"), c("C", "D"))
ggboxplot(df ,x = "ColB", y = "ColA",
color = "ColB", palette = "jco",
add = "jitter")+stat_compare_means(comparisons = my_comparisons)