I'm testing for a relationship between different crosses of blueberry varieties and their adjusted fruit mass (a proxy for realized yield). I created a mixed linear model and found a significant effect but I wanted to know which crosses are best. So, I used emmeans to perform a post hoc test with Tukey. I now want to add those p-values to my boxplot (or stars to indicate a significant difference) but I am struggling on how to do this. This code works but it results in brackets with no star/value/etc and still includes capital "NS". Is there a better way to approach this? I've included a photo of my data for reference.
sm <- lmer(adj_fruitmass ~ pair + (1|plantid), data = pilot)
# Post-hoc test
cmpr <- list(c("Bluecrop", "Duke"),
c("Bluecrop", "Reka"),
c("Duke", "Bluecrop"),
c("Duke", "Reka"))
emmeans(sm, pairwise ~ pair, adjust = "tukey")
# Change one NA to zero to fix order of boxplots
pilot$adj_fruitmass[is.na(pilot$adj_fruitmass)] <- 0
# Add post-hoc p-values to boxplot
pilot %>%
ggplot(aes(x = reorder(Pollen_donor, adj_fruitmass), y = adj_fruitmass, na.rm = T)) +
geom_boxplot() +
geom_point() +
labs(x = "Pollen donor", y = "Adjusted fruit mass") +
theme_classic() +
facet_grid(~Variety) +
stat_compare_means(comparisons = cmpr,
label = "p.signif",
hide.ns = TRUE,
tip.length = 0.01,
symnum.args = list(cutpoints = c(0, 0.0001, 0.001, 0.01, 0.05, 1),
symbols = c("****", "***", "**", "*", "ns")))