我试图使用ggpubr包在boxplot上添加标签。这是我使用的代码:
library(ggplot2)
library(ggpubr)
compare_means(len ~ supp, data = ToothGrowth, method="t.test", paired=TRUE, group.by = "dose")
# Box plot facetted by "dose"
p1 <- ggboxplot(ToothGrowth, x = "supp", y = "len", xlab=F,
color = "supp", palette = "jco",
facet.by = "dose", add="mean", short.panel.labs = FALSE)
# Use only p as label.
p2 <- p1 + stat_compare_means(method = "t.test", paired = T, label = "p")
p2
样本数据(ToothGrowth)
15.5 VC 1.0
23.6 VC 2.0
18.5 VC 2.0
33.9 VC 2.0
25.5 VC 2.0
26.4 VC 2.0
32.5 VC 2.0
26.7 VC 2.0
21.5 VC 2.0
23.3 VC 2.0
29.5 VC 2.0
15.2 OJ 0.5
21.5 OJ 0.5
17.6 OJ 0.5
9.7 OJ 0.5
14.5 OJ 0.5
10.0 OJ 0.5
8.2 OJ 0.5
9.4 OJ 0.5
16.5 OJ 0.5
9.7 OJ 0.5
有没有办法将平均值作为文本添加(除了点使用:add =&#34; mean&#34;)
如果可能,我希望将平均值文本放在&#34; p = 0.000&#34;它来自&#34; stat_compare_means&#34;代码。
另外,有没有办法删除分组绘图时自动生成的图例?
我想制作的最终情节如下:
提前致谢!