You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Dropped cases are taken into account for the dodging of geom_boxplot but not geom_violin #5002
Dropped cases are taken into account for dropped groups are still taken into account for the dodging of geom_boxplot but not geom_violin
The issue is detailed with reproducible code, a diagnosis, and solution from a commenter on StackOverflow. It appears there may be an inconsistency between geom_violinn and geom_boxplot.
changed the title [-]Dropped cases are taken into account for dropped groups are still taken into account for the dodging of geom_boxplot but not geom_violin[/-][+]Dropped cases are taken into account for the dodging of geom_boxplot but not geom_violin[/+]on Sep 29, 2022
library(ggplot2)
df<-data.frame(
x=factor(rep(1:2, each=4)),
y= rep(1:2, 4),
g= rep(c("A", "A", "B", 'B'), 2)
)
p<- ggplot(df, aes(x, y, fill=g)) +
geom_violin(position= position_dodge(0.9)) +
geom_boxplot(position= position_dodge(0.9))
p %+% head(df, -1)
#> Warning: Groups with fewer than two data points have been dropped.
Activity
[-]Dropped cases are taken into account for dropped groups are still taken into account for the dodging of geom_boxplot but not geom_violin[/-][+]Dropped cases are taken into account for the dodging of geom_boxplot but not geom_violin[/+]teunbrand commentedon Jan 4, 2023
Here is a slightly more minimal reprex:
Created on 2023-01-04 by the reprex package (v2.0.1)