I am trying to create a grouped Boxplot in R Studio with ggplot2.
My Data looks like this:
(4 different APP.mm values in total)
And a sample dput()
of my dataset:
structure(list(APP.mm = c(408.5, 408.5, 408.5, 408.5, 408.5,
408.5, 408.5, 408.5, 408.5, 408.5, 408.5, 237.5, 237.5, 237.5,
237.5, 237.5, 237.5, 237.5, 237.5, 237.5, 237.5, 237.5, 237.5,
237.5, 237.5, 132.1, 132.1, 132.1, 132.1, 132.1, 132.1, 132.1,
274, 274, 274, 274, 274, 274, 274, 274, 274), Weight_mg = c(112,
106.72, 118.4, 62.3, 86.2, 70.3, 56.5, 71, 61.4, 61.7, 62.7,
81.1, 125.5, 71, 120.4, 75.3, 68.1, 95.9, 77.5, 95.5, 85.3, 64.1,
27.6, 20.5, 77.9, 86.3, 120, 100.2, 86.4, 67.8, 104.4, 90.1,
71.1, 89, 77.4, 77.1, 60.5, 78.7, 87.9, 71.1, 76.5), Germination = c(0L,
1L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 1L, 1L,
1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 1L,
1L, 0L, 1L, 1L, 1L, 0L, 1L, 0L)), .Names = c("APP.mm", "Weight_mg",
"Germination"), row.names = c(6L, 7L, 8L, 9L, 88L, 89L, 90L,
91L, 92L, 93L, 94L, 2111L, 2112L, 2113L, 2114L, 2115L, 2116L,
2117L, 2118L, 2119L, 2120L, 2121L, 2122L, 2123L, 2124L, 2674L,
2675L, 2676L, 2677L, 2678L, 2679L, 2680L, 3193L, 3194L, 3195L,
3196L, 3197L, 3198L, 3199L, 3200L, 3201L), class = "data.frame")
I am now trying to create a Grouped Boxplot with the APP.mm on the x-Axis, the Weight on the Y-Axis and the values grouped by APP.mm into Germination Succes (1) oder No Germination Success (0)
I tried these codes for R:
ggplot(data = gallsdtg, aes(x=APP.mm, y=Weight_mg)) +
geom_boxplot(aes(fill=Germination))
Warning message:
Continuous x aesthetic -- did you forget aes(group=...)?
ggplot(data = gallsdtg, aes(x=APP.mm, y=Weight_mg)) +
geom_boxplot(aes(group=Germination))
qplot(gallsdtg$APP.mm, gallsdtg$Weight_mg,
fill=factor(galls$Germination), geom="boxplot")
resulting in this plot:
I tried the exact same code on the same structure of Data just from a different location and got the plot I wanted.
qplot(germination2017extras$APP.mm, germination2017extras$Weight_mg,
fill=factor(germination2017extras$Germination), geom="boxplot",
xlab="mean APP in mm", ylab="Weight in mg", ylim=c(0,200))
Can someone tell me what I am doing wrong here? Thank you so much!