I am trying to make a box plot from summary statistics generated from simulation data--I am not plotting raw data. The summary data look like this:
require(tidyverse)
df <- tibble(Source = c("A","A","B","B","C","C"),
Group = c("y","n","y","n","y","n"),
y2.5 = c(0.592,0.471,0.182,0.285,0.024,0.031),
y25 = c(0.633,0.53,0.217,0.325,0.059,0.081),
y50 = c(0.673,0.547,0.24,0.347,0.08,0.106),
y75 = c(0.699,0.58,0.267,0.370,0.103,0.130),
y97.5 = c(0.764,0.61,0.312,0.414,0.146,0.173))
I want to generate box plots for each Source along the x-axis, paired by Group. As you can see, there is one set of summary values for each combination of group and source.
I see from the vignettes that geom_boxplot(aes()) accepts summary values plotted this way:
ggplot(df, aes(Source, group = Group))+
geom_boxplot(aes(ymin = y2.5, lower = y25, middle = y50, upper = y75, ymax = y97.5),
stat = "identity")
But this code run on these data generates this error:
Error: Can't draw more than one boxplot per group. Did you forget aes(group = ...)?
I have moved the group argument into the box plot aes() call but this produces the same error message. This feels a lot like a simple problem caused by some late-night oversight but I just can't see it... maybe I have been staring too long. Any help with this would be much appreciated.


