Я не могу понять, как заставить их работать в этой группе, используя geom_signif
.Смотрите первую часть моей попытки.Я смог заставить его работать, используя ggpubr
и stat_compare_means
, который, я считаю, является расширением geom_signif
.
ggplot(df, aes(country,Sepal.Length)) +
geom_boxplot(position="dodge",aes(fill=petal.colour)) +
facet_wrap(~Species, ncol=3) +
geom_signif(comparisons = list(c("France", "UK")), map_signif_level=TRUE,
tip_length=0,y_position = 9, textsize = 4) +
geom_signif(y_position = 8.5,
xmin=c(0.75,1.75), xmax=c(1.25,2.25), tip_length=0, map_signif_level = c("***" = 0.001, "**" = 0.01, "*" = 0.05))
Warning messages:
1: In wilcox.test.default(c(4.9, 4.7, 5, 5.4, 5, 4.4, 5.4, 4.8, 4.3, :
cannot compute exact p-value with ties
2: In wilcox.test.default(c(7, 6.9, 5.5, 5.7, 6.3, 6.6, 5.2, 5.9, 6, :
cannot compute exact p-value with ties
3: In wilcox.test.default(c(6.3, 5.8, 6.3, 6.5, 4.9, 7.3, 7.2, 6.5, :
cannot compute exact p-value with ties
4: Computation failed in `stat_signif()`:
arguments imply differing number of rows: 6, 0
5: Computation failed in `stat_signif()`:
arguments imply differing number of rows: 6, 0
6: Computation failed in `stat_signif()`:
arguments imply differing number of rows: 6, 0
Используя ggpubr
и stat_compare_means
.Обратите внимание, что вы можете использовать разные метки, тесты и т. Д. См. ?stat_compare_means
.
library(ggpubr)
ggplot(df, aes(country,Sepal.Length)) +
geom_boxplot(position="dodge",aes(fill=petal.colour)) +
facet_wrap(~Species, ncol=3) +
stat_compare_means(aes(group = country), label = "p.signif", label.y = 10, label.x = 1.5) +
stat_compare_means(aes(group = petal.colour), label = "p.format", label.y = 8.5)