I'm trying to create a line graph and keep getting an error when I add in the error bars (just getting started with R, so apologies!). I'm not sure why - help would be appreciated!
Group = c("a","a","b","b","a","a","b","b")
Time = c(1,2,1,2,1,2,1,2)
Code = c("A","A","A","A","B","B","B","B")
Mean = (2,6,7,5,6,1,2,8)
SE = c(1.9,1.7,1.5,1.3,2,1.8,2.3,1.5)
dataset=data.frame(Group,Time,Code,Mean,SE)
ggplot(data=dataset) + geom_line(aes(x=Time,y=Mean,colour=Code,linetype=Group))+
scale_x_continuous(breaks=c(1,2)) +
scale_linetype_manual(values=c(2,1)) +
geom_point(aes(x=Time,y=Mean,colour=Code,linetype=Group)) +
geom_errorbar(aes(ymin=Mean-SE,ymax=Mean+SE),width=.1,position=dodge)
The problem has to do with the last line -- code works fine without it. But with it, I get: Error in eval(expr, envir, enclos) : object 'x' not found
.
So what am I doing wrong with the geom_errorbar
line?