I would like side by side box plots (total and ELISA) by media type. I saw in other chats that I need to melt the data. When I do this I get the following
Error: stat_boxplot requires the following missing aesthetics: y
My data:
media total ELISA
surface 1.3 2.7
surface 5.2 6.5
surface 0.9 2.9
surface 0.7 2.1
porewater 376.8 651.0
porewater 288.7 308.0
porewater 32.3 63.3
porewater 69.7 184.0
porewater 116.0 11.4
porewater 31.6 51.5
porewater 38.6 97.5
porewater 63.2 152.0
porewater 118.0 254.0
porewater 1147.5 4174.0
porewater 626.6 798.0
porewater 39.2 81.8
porewater 3.3 7.5
porewater 70.3 231.5
porewater 1.7 3.2
sediment 567.0 1454.1
sediment 24.0 70.7
sediment 13.7 23.9
sediment 16.9 105.7
sediment 39.7 5.9
sediment 8.2 17.6
sediment 27.4 85.0
sediment 14.7 30.8
My code:
library(reshape2)
elisa.m <- melt(elisa, media.vars='media', measure.vars=c('total','ELISA'))
library(ggplot2)
p <- ggplot(elisa.m) +
geom_boxplot(aes(x = media, y=value)) +
stat_boxplot(geom = "errorbar", width = 0.5)
I'm not sure why this isn't working. Should I be naming it something other than value?