ggstatsplot
ggstatsplot copied to clipboard
Dropping unused factors result in unconsistent plots when grouping
https://github.com/IndrajeetPatil/ggstatsplot/blob/1fa219dd7440af5955ddc34aaf1911549422e10e/R/ggbarstats.R#L79
If you make the drop unused levels optional with an argument, more consistent plots can be obtained.
Worked for me:
- Comment this line:
https://github.com/IndrajeetPatil/ggstatsplot/blob/1fa219dd7440af5955ddc34aaf1911549422e10e/R/helpers_ggcatstats_graphics.R#L21
-
Add an drop.unused.levels argument to the function
-
Change this line and add another one:
https://github.com/IndrajeetPatil/ggstatsplot/blob/1fa219dd7440af5955ddc34aaf1911549422e10e/R/ggbarstats.R#L150
paletteer::scale_fill_paletteer_d(paste0(package, "::", palette), name = "",
drop = drop.unused.levels) +
scale_x_discrete(drop=drop.unused.levels)
I am not sure how this affects to the computation of statistics or further side effects, so I am not submitting a pull request for the time.