0
バーの順序をBefore-Afterに変更したいと思います。ggplotの塗りつぶしの順番は、stat = identityとdodgeです。
私は他の同様の投稿を見ました:例えば ggplot bar plot with facet-dependent order of categoriesしかし、これにどのように適用するかを理解できませんでした。
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)))