is_it_normal {traumar} | R Documentation |
Exploratory Data Analysis, Normality Testing, and Visualization
Description
is_it_normal()
calculates descriptive statistics and conducts univariate
normality testing on one or more numeric variables in a dataset using a
selected statistical test. Optional plots are included for one variable at a
time, only. Results are returned as a named list containing summaries and,
optionally, normality tests and/or diagnostic plots.
Usage
is_it_normal(
df,
...,
group_vars = NULL,
seed = 10232015,
normality_test = NULL,
include_plots = FALSE,
plot_theme = traumar::theme_cleaner
)
Arguments
df |
A |
... |
One or more unquoted column names from |
group_vars |
Optional. A character vector of column names in |
seed |
A numeric value passed to |
normality_test |
A character string specifying the statistical test to
use. Must be one of: |
include_plots |
Logical. If |
plot_theme |
A |
Details
If the data do not meet the test requirements for a chosen test of normality,
is_it_normal()
will not run the tests.Normality tests may yield differing results. Each test has distinct assumptions and sensitivity. Users should verify assumptions and consult test-specific guidance to ensure appropriate use.
The function will abort with helpful CLI messages if input types or structures are incorrect.
If plotting is enabled, and
nrow(df) > 10000
, a warning is issued as plotting may become computationally expensive.
Value
A named list with the following elements:
- descriptive_statistics
A
tibble
of summary statistics for each variable.- normality_test
A
tibble
of test statistics and p-values (ifnormality_test == TRUE
).- plots
A patchwork object containing four plots (if
include_plots = TRUE
and one variable supplied).
Note
Supported normality tests are below. Please check the specifications of these tests in the corresponding documentation.
Shapiro-Wilk (
stats::shapiro.test()
)Kolmogorov-Smirnov (
stats::ks.test()
)Anderson-Darling (
nortest::ad.test()
)Lilliefors (
nortest::lillie.test()
)Cramer-von Mises (
nortest::cvm.test()
)Pearson (
norest::pearson.test()
)Shapiro-Francia (
nortest::sf.test()
)
Please note that if grouped plotting is enabled, each group will generate its own set of plots. This may flood your IDE or console. Plan your use of this functionality with care to avoid lags or unwanted outputs.
Author(s)
Nicolas Foss, Ed.D., MS