I have a dataset with columns including animal id, treatment, sex, and mean speed. I attempted to make a ggplot barplot of the mean of the mean speed vs treatment split by sex (shown below). (BTW the mean speed is for each animal, and I want to plot the mean of all the animals in a given treatment/sex). My plot does not seem to be putting in the mean though.
I know that I could get the mean using dplyr and then put that into the plot, but I was hoping I could just have ggplot do it (if there is a reason I shouldn’t do this, I’d be interested in learning why).
NMXDR_OF <- read_csv("~/Desktop/R Files/5_3_24_OF_NMXDR_FinalData.csv")
ggplot(data = NMXDR_OF, mapping = aes(x=Treatment, y="Mean speed", fill = Treatment)) + geom_bar(stat="summary", fun="mean") + facet_wrap("Sex")+ geom_jitter(width = 0.1) + stat_summary(geom = "errorbar", fun.data = mean_se)
When I do this, the mean and the error bars are not plotted though (https://i.sstatic.net/8PvvynTK.png). I made sure that my variable “mean speed” is numeric.
Elena Morales-Grahl is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.