I have been trying to add error bars to my ggplot with no luck. The ggplot is based on the prevalence of Cryptosporidium in two housing categories (indoor and outdoor). I would like to add error bars to the respective bars but I keep getting something like this:
My code looks like this:
#Housing Graph % Prevalence
yesHousingonly<-cows$Housing.Status[cows$Result == "yes"]
df5<-data.frame(yesHousingonly)
ggplotHousing<-ggplot(df5, aes(x = yesHousingonly, fill=yesHousingonly)) + geom_bar(aes(y = (..count..)/sum(..count..))) + theme_bw()
ggplotHousing + xlab("Housing Status") + ylab("% Prevalence") + scale_fill_brewer(name="Housing Status", labels=c("Indoor", "Outdoor"), palette = "PuRd") + scale_x_discrete(breaks=c("indoor", "outdoor"),labels=c("Indoor", "Outdoor"))
I have tried using the geom_errorbar() function but the ymin and ymax values I am inserting always end up yielding something like the above.
Thanks in advance for any help!