I have a facet_wrapped plot with 5 facets, that have different numbers of boxplots in them.
I wanna pairwise compare all of them if they differ siginficantly from each other, ideally already giving the p-value IN the graph.
My code:
data.csv %>%
group_by(method, year) %>%
ggplot(aes(crop, H, fill = crop)) +
geom_boxplot() +
labs(x = "", y = "Shannon Index per field") +
scale_fill_manual(
values = c(
"antiquewhite4", "burlywood4", "cornsilk2",
"cornsilk", "antiquewhite3", "antiquewhite2"
)
) +
facet_wrap(~method, scales = "free_x") +
stat_compare_means(aes(group = crop), label = "p.signif")
What I tried:
stat_compare_means
-> doesn't seem to work, gives the wrong values (I think it compares ALL barleys with ALL whetas and not only the ones IN one of the facets).stat_pvalue_manual(stat.test)
-> gives me errors, doesn't find object stat.test no matter how I put the object before
What I need: for it to work without making every facet a single boxplot graph and then adding all together later thanks a lot for your help!!!