When I plot barplot like this:
p<- ggplot(corttestunitedcol, aes(x=Sex, y=mean, fill=Treatment_Status)) +
geom_bar(stat="identity", color="black",
position=position_dodge()) +
geom_errorbar(aes(ymin=mean-sd, ymax=mean+sd), width=.2,
position=position_dodge(.9))
beautiful. What I want.
However, if I add anything to this, it get
Error:
mappingmust be created byaes()
For example adding titles:
p<- ggplot(corttestunitedcol, aes(x=Sex, y=mean, fill=Treatment_Status)) +
geom_bar(stat="identity", color="black",
position=position_dodge(),
labs(title = "Corticosterone",
y = "mean plasma Corticosterone (pg/ml)", x = "")) +
geom_errorbar(aes(ymin=mean-sd, ymax=mean+sd), width=.2,
position=position_dodge(.9))
Or
p<- ggplot(corttestunitedcol, aes(x=Sex, y=mean, fill=Treatment_Status)) +
geom_bar(stat="identity", color="black",
position=position_dodge(),
facet_wrap(~Sex)) +
geom_errorbar(aes(ymin=mean-sd, ymax=mean+sd), width=.2,
position=position_dodge(.9))
How do I fix this?
geom_*function, just add after all geoms+ facet_wrap(~Sex)labsin the "For example adding titles:" code.