Closed duttashi closed 7 years ago
Solution
This warning is generated because you are trying to plot continuous variables on x and y-axis. Although, the box plot will be generated but the warning will remain. The resolve this, remember, to plot the categorical on x-axis and continuous on y-axis.
The reason is ggplot2
, draws boxplots vertically (categorical along x, continuous along y) and you are trying to draw them horizontally (continuous along x, continuous along y). The correct code will be;
> str(data_balanced)
'data.frame': 610 obs. of 10 variables:
$ VisitRsrc : int 11 22 91 90 41 64 25 61 25 80 ...
$ Relation : Factor w/ 2 levels "Father","Mother": 1 2 1 1 2 1 1 1 1 1 ...
$ StudAbsnDay: Factor w/ 2 levels "Above-7","Under-7": 2 1 2 2 1 1 1 1 1 2 ..
>ggplot(data = data_balanced, aes(x=Relation, y=raisedhands, fill=gender)) +
geom_boxplot()+
scale_fill_discrete(name="Gender")+
facet_grid(~StudAbsnDay)
Reference: See this SO answer by user Brian Diggs
Issue: "warning message: position_dodge requires non-overlapping x intervals", when plotting a box plot is generated. This warning is generated, when plotting continuous variables on both x and y- axis