normal_test.Rd
Conducts normality tests for a specified variable, optionally by group. Supports automatic testing and interactive visualization.
normal_test(data = NULL, var = NULL, group = NULL, norm = "auto")
A data frame containing the variables to be tested.
A character string specifying the numeric variable in data
to test.
A character string specifying the grouping variable in data
. If NULL
, treated as one group.
Control parameter for test behavior. Accepts:
'auto'
: Automatically decide based on p-values, but the same as 'ask'
when n > 1000, default
'ask'
: Show p-values, plots QQ plots and prompts for decision
TRUE
/'true'
: Always returns TRUE
FALSE
/'false'
: Always returns FALSE
A logical value:
TRUE
: data are normally distributed
FALSE
: data are not normally distributed
Automatically selects test based on sample size per group:
n < 3: Too small, assuming non-normal
3 ≤ n ≤ 50: Shapiro-Wilk test
50 < n<= 1000: D'Agostino Chi2 test, instead of Kolmogorov-Smirnov test
n > 1000: Show p-values, plots QQ plots and prompts for decision references: 1.https://www.graphpad.com/guides/prism/latest/statistics/stat_choosing_a_normality_test.htm 2.D’Agostino, R.B. (1971) An Omnibus Test of Normality for Moderate and Large Size Samples. Biometrika, 58, 341-348.
normal_test(iris, "Sepal.Length", "Species", norm = "auto")
#> [1] TRUE
normal_test(iris, "Sepal.Length", "Species", norm = TRUE)
#> [1] TRUE