Errorbar of same variable do not get conditionally seperated when using facet_wrap

39 views Asked by At

I have the following dataset:

Figure: dataset

I want to create three bar plots side by side using facet. I have the following code in R:

  ggplot(nod.stat, aes(fill=Fix, x=Fix, y=mean)) + 
  geom_bar(stat='identity', position=position_dodge(width=0.9)) + 
  geom_errorbar(aes( ymin=mean-se, ymax=mean+se), position = position_dodge(width = 0.90), width=0.2) +
  facet_wrap(.~variable, scales='free')

But this keeps adding all three SE from same Fix condition like the following graph: Figure: output bar plot

How can I make sure that there is only one errorbar respective to each bar?

0

There are 0 answers