Error adding geom_errorbar in ggplot2

2.3k Views Asked by At

I'm trying to add some errorbars to my scattergraph and I can't work out what's wrong. Code below:

growth_means <- read.csv("growth_means.csv")

plot = ggplot() + 
  geom_point(aes(x=HAS, y=Width, colour=Genotype), 
             size=1.5, data=growth_means, stat="identity") + 
  geom_errorbar(inherit.aes = FALSE, 
                ymin=Width-Width_SE, ymax=Width-Width_SE)

plot

Data below:

> head(growth_means)


HAS DAS      Width    Width_SE    Length   Length_SE       Area     Area_SE Genotype
1 120   5 0.07021040 0.002033000 0.1064330 0.006007115 0.00593173 0.000428288       WT
2 120   5 0.09270133 0.006270253 0.1324452 0.009192732 0.01053883 0.001126512    da1-1
3 120   5 0.10211586 0.005986254 0.1468009 0.004522738 0.01273033 0.001277010       bb
4 120   5 0.10938800 0.006663103 0.1560210 0.015423139 0.01382478 0.001893295  da1-1bb
5 168   7 0.24769211 0.014692246 0.3162221 0.016811098 0.06381803 0.006592822       WT
6 168   7 0.29798890 0.007262811 0.3896144 0.009202582 0.09314732 0.001129070    da1-1

I can plot a perfectly good scatterplot but get:

Error in layer(data = data, mapping = mapping, stat = stat, geom = GeomErrorbar, : object 'Width' not found

when I run the above code.

0

There are 0 best solutions below