Add stats to boxplot in R
1
0
Entering edit mode
6 months ago
G.S ▴ 60

Hi,

I need help to improve the stat on this plot. First, I am not sure how to move the Kruskal-wallis above the others pvalue. Then, I want to add line below the kruskal-wallis test?

I used this code to generate:

gv_interest = ggboxplot(dat_viogenes, x = "Condition", 
                      y = colnames(dat_viogenes)[1:19],
                      combine = T,
                      fill="Condition") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) + 
  stat_compare_means(comparisons = my_comparisons,method = "wilcox.test",
                     label.y = 2.5,
                     method.args = list(alternative="greater"))+

   stat_compare_means(method = "kruskal.test", label.y = 2, size= 5, hjust= 0.09)

gv_interest

Any help would be much appreciated and thanks in advance

boxplot

stats R • 586 views
ADD COMMENT
0
Entering edit mode
6 months ago
Lélé ▴ 10

Hi,

Have you tried switching the order of the stat_compare_means for the Wilcox with the one for kruskall-Wallis ?

ADD COMMENT
0
Entering edit mode

Great. thats work. Do you know how can I remove the kruskall-Wallis name from the plot? Also I would like to draw a line under the kruskall-Wallis P value? Is it possible to use symbol instead of p value ? Thanks very much for your helpenter image description here

ADD REPLY
1
Entering edit mode

To remove "Kruskall Wallis" you can try adding the argument label="p" or label = "p.signif" which displays the p-value or *** like this:

stat_compare_means(method = "kruskal.test", size = 5, hjust = 0.09, label = "p.signif")

ADD REPLY
0
Entering edit mode

Thanks. Thats work

ADD REPLY

Login before adding your answer.

Traffic: 1796 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6