I am simply trying to add error bars to a side by side bar plot using ggplot. I think data is arranged correctly as per below. I want to graph differences in fecundity between inbred and outbred populations derived from populations with (+SS) and without (-SS) sexual selection.
inbreeding SS Fecundity se
1 Inbred +SS 5.60 0.8596205
2 Inbred +SS 7.40 1.1639316
3 Inbred +SS 6.25 1.2457824
4 Inbred +SS 1.40 0.1854050
5 Outbred +SS 7.70 1.2377824
6 Outbred +SS 6.30 0.6613384
7 Outbred +SS 2.35 1.0137865
8 Outbred +SS 8.27 1.2775966
9 Inbred -SS 9.15 1.7595977
10 Inbred -SS 12.50 1.7464249
11 Inbred -SS 10.95 1.9063260
12 Inbred -SS 3.65 1.2036676
13 Outbred -SS 7.65 1.5564382
14 Outbred -SS 9.10 1.5250539
15 Outbred -SS 5.75 1.3315503
16 Outbred -SS 3.65 0.9821432
The code I am using for making the plot is
ggplot(Inbreeding27Means.ggplot,aes(x=SS,y=Fecundity,fill=inbreeding))+
geom_bar(stat="identity",position=position_dodge())+
geom_errorbar(aes(ymin=Fecundity-se,ymax=Fecundity+se),width=.2,
position=position_dodge(.9))
Which generally came from the R cookbook website here
What appears to happen is that multiple error bars within each column/bar are added for each group of my grouping variable (inbreeding) ( I think). Sorry my reputation is not quiet high enough to add a picture. So I hope code is clear. The side by side bar graphs on the R cookbook website is essentially what I am aiming for except my variable (SS) on x-axis has only two groups.
Obviously I'd like to just have one error bar per bar on the plot. If someone could suggest what I may have done wrong here i'd much appreciate it.
