I'm trying to plot a scatter graph with error bars in R using categorical data on the x axis, using the following code:
Nesk <- read.table("E:\\R stuff\\Chapter 2\\Boxplots of nb\\NEnbNOINF.txt", header=TRUE, fill=TRUE)
pd <- position_dodge(0.2)
ggplot(Nesk, aes(x = TYPE, y = NB, color = TYPE)) +
geom_jitter() +
geom_point(position = pd) +
geom_errorbar(aes(ymin = LC, ymax = UC), position = pd) +
theme_bw() +
theme(axis.title = element_text(face = "bold")) +
ylab("Nb")
However, I can't get the error bars on the jittered points. I end up with this https://i.stack.imgur.com/q3ayt.jpg. Sorry all, don't have the reputation to directly insert images
I've tried using position dodge however I'm aware that it just separates the points by category (COL, LIN, NOM) as opposed to within each category. Is there any way I can jitter the points and attach error bars to these? I've seen some posts with fixes for this, but I think somewhere along the line an update invalidated those.
Thanks in advance!