I would like to change the order of the bars to Before-After.
I looked at other similar posts eg: ggplot bar plot with facet-dependent order of categories but couldn't figure out how to apply those to this.
df<-data.frame(
When<-c('Before', 'Before','After','After'),
Group<-c('Untreated','Treated','Untreated','Treated'),
Mean<-c(3,4,3,5)
)
ggplot(df, aes(x = Group, y = Mean, fill = When))+
geom_bar(stat='identity', position=dodge) +
scale_x_discrete(limits = rev(levels(df$Group)))