I have been using R just for past 3 days and have got most of the code below through research which I have adapted to suit my needs. It works perfectly well. I want to be able to label/annotate the error bars on the standard errors with ( B, A*, A, A) respectively. Below is the working code;
cat<-rep(c("E","F","G","H"),each=12)
var2=rnorm(48,10)*(rep(rpois(4,.2),each=12)/8+1)
ds<-data.frame(cat,var2)
lbls<- c("B","A*","A","A")
stderr <- function(x){sqrt(var(x,na.rm=TRUE)/length(na.omit(x)))}
lowsd <- function(x){return(mean(x)-stderr(x))}
highsd <- function(x){return(mean(x)+stderr(x))}
cols <- c("red", "yellow", "green", "blue")
ggplot(ds,aes(cat,var2, fill=cat))+
ggtitle("Asem beba Dabi")+
xlab("Soil Sample Sites\n\n Fig 1 shows...") + ylab("Mass or Water(mg)") +
# first layer is barplot with means
stat_summary(fun.y=mean, geom="bar", position="dodge", colour="white")+
# second layer overlays
stat_summary(fun.y=mean, fun.ymin=lowsd, fun.ymax=highsd, geom="errorbar", position="dodge",color = 'blue', size=.5)
This is the bit I am struggling with
geom_text(aes(label=lbls), position=position_dodge(width=0.9), vjust=-0.25)
This is a school assignment and any help will be highly appreciated