I have a question that is quite similar to another one: Using ggsignif with grouped bar graphs and facet_wrap not working
My question is: Is it possible to add a comparison line OVER the two facets? In this case: a comparison between S1 and S2, the facet variable Group?
This is the data and the plot of the other question:
dat <- data.frame(Group = c("S1", "S1", "S2", "S2"),
Sub = c("A", "B", "A", "B"),
Value = c(3,5,7,8))
ggplot(dat, aes(Group, Value)) +
geom_bar(aes(fill = Sub), stat="identity", position="dodge", width=.5) +
facet_grid(~ Group, scales = "free")
What I want is a comparison line with geom_signif
over the two facets (Variable Group
with levels S1
and S2
. Is this possible?
If not, is there a way to do nearly the same but another way?