# Set your working directory # then remove the "#" in front of the setwd line #setwd("your working directory here") # Read the data myData<-read.csv("compensation.csv") # Extract the useful information n.fruit<-tapply(myData$Fruit, list(myData$Grazing), length) mean.fruit<-tapply(myData$Fruit, list(Grazing=myData$Grazing), mean) sd.fruit<-tapply(myData$Fruit, list(Grazing=myData$Grazing), sd) # The main figure mids<- barplot(mean.fruit, xlab="Treatment", ylab="Fruit production", ylim=c(0,100)) # The error bar arrows(mids, mean.fruit+sd.fruit, mids, mean.fruit-sd.fruit, angle=90, code=3) # The little text at the bottom text(mids,5,paste("N= ",n.fruit))