Hi there!
I have a small dataset that contains the following: SNP Count (numerical value), Caste (categorical value, "nymph", "worker", "soldier"), and Location (categorical value, "boston", "raleigh", "toronto"):
Location Caste SNP Count
Toronto Worker 150536
Raleigh Worker 156609
Boston Worker 118797
Toronto Soldier 150585
Raleigh Soldier 155153
Boston Soldier 128518
Raleigh Nymph 155056
Boston Nymph 131711
I used ggplot2 in R studio to create a graph to represent all of the data:
df2 <- read.csv("VariantsTable.csv")
p<-ggplot(df2,aes(x=df$Caste,y=df$SNP.Count))
Location<-factor(df2$Location)
p<-p+geom_point(aes(colour=Location),size=3) + theme_bw()
p+xlab("Caste")+ylab("SNP Count")
Which gives this output:
I want to add three values onto this plot, a mean for each of the caste groups (with error bars). So there would be an extra dot within each caste group to represent the mean and SD of the existing dots. I have been trying to manipulate existing code to do so, but have not succeeded. Does anyone have any suggestions? Thanks.
Thank you so much! I was playing around with geom_point and geom_error arguments but had some problems I couldn't work out (I am pretty new to this). This is awesome, thanks once again.