View source: R/vis_group_normality.R
| vis_group_normality | R Documentation |
vis_group_normality checks for normality of each group separately using
the Shapiro-Wilk and Anderson-Darling tests. The null hypothesis is that
each group is normally distributed. The function generates histograms
with normal distribution overlays and Q-Q plots to visually assess normality.
The layout is always 2 rows × k columns (histograms on top, Q-Q plots on bottom).
vis_group_normality(
samples,
groups,
conf.level = 0.95,
samplename = "",
groupname = "",
cex = 1
)
samples |
Numeric vector; the dependent variable. |
groups |
Factor or vector; the grouping variable (2 to 8 groups for visual display). |
conf.level |
Numeric; confidence level (default: 0.95). Used to determine alpha = 1 - conf.level for normality test interpretation. |
samplename |
Character; label for the y-axis (default: ""). |
groupname |
Character; label for the x-axis (default: ""). |
cex |
Numeric; scaling factor for plot text and symbols (default: 1). |
Layout is always 2 rows × k columns:
Top row: Histograms with normal overlay for each group
Bottom row: Q-Q plots for each group
For more than 8 groups, a tabular summary is provided instead of plots.
A list containing:
List of Shapiro-Wilk test results for each group
List of Anderson-Darling test results for each group
Number of groups
Names of the groups
# Two groups (like t-test)
vis_group_normality(ToothGrowth$len, ToothGrowth$supp)
# Three groups
ToothGrowth$dose <- as.factor(ToothGrowth$dose)
vis_group_normality(ToothGrowth$len, ToothGrowth$dose)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.