Easily make nice per-group density and QQ plots
through a wrapper around the ggplot2
and qqplotr
packages.
nice_normality(
data,
variable,
group = NULL,
colours,
groups.labels,
grid = TRUE,
shapiro = FALSE,
title = NULL,
histogram = FALSE,
breaks.auto = FALSE,
...
)
A plot of classes patchwork and ggplot, containing two plots,
resulting from nice_density
and nice_qq
.
The data frame.
The dependent variable to be plotted.
The group by which to plot the variable.
Desired colours for the plot, if desired.
How to label the groups.
Logical, whether to keep the default background grid or not. APA style suggests not using a grid in the background, though in this case some may find it useful to more easily estimate the slopes of the different groups.
Logical, whether to include the p-value from the Shapiro-Wilk test on the plot.
An optional title, if desired.
Logical, whether to add an histogram on top of the density plot.
If histogram = TRUE, then option to set bins/breaks
automatically, mimicking the default behaviour of
base R hist()
(the Sturges method). Defaults to
FALSE
.
Further arguments from nice_qq()
and
nice_density()
to be passed to nice_normality()
Other functions useful in assumption testing:
nice_assumptions
, nice_density
,
nice_qq
, nice_var
,
nice_varplot
. Tutorial:
https://rempsyc.remi-theriault.com/articles/assumptions