Вы были близки, аргумент family =
идет прямо в stat_compare_means()
.
С help(stat_compare_means)
:
Usage
stat_compare_means(mapping = NULL, data = NULL, method = NULL,
paired = FALSE, method.args = list(), ref.group = NULL,
comparisons = NULL, hide.ns = FALSE, label.sep = ", ",
label = NULL, label.x.npc = "left", label.y.npc = "top",
label.x = NULL, label.y = NULL, tip.length = 0.03,
bracket.size = 0.3, step.increase = 0, symnum.args = list(),
geom = "text", position = "identity", na.rm = FALSE,
show.legend = NA, inherit.aes = TRUE, ...)
<snip>
... other arguments to pass to geom_text or geom_label.
Таким образом, этот код должен делать то, что вы хотите.
ggboxplot(ToothGrowth, x = "supp", y = "len",
color = "supp", palette = "jco",
add = "jitter",
facet.by = "dose", short.panel.labs = FALSE) +
stat_compare_means(label = "p.format",family = "Times New Roman")
#Use this if on Windows: stat_compare_means(label = "p.format",family = "TT Times New Roman")