normal_test.RdConducts 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, 50] Shapiro-Wilk test
(50, 1000]: D'Agostino Chi2 test, instead of Kolmogorov-Smirnov test
n > 1000: Show p-values, plots QQ plots and prompts for decision
normal_test(iris, "Sepal.Length", "Species", norm = "auto")
#> [1] TRUE
normal_test(iris, "Sepal.Length", "Species", norm = TRUE)
#> [1] TRUE