ntest | R Documentation |
This function performs a Shapiro-Wilk normality test on multiple variables in a dataframe. It returns the results in a tidy format.
ntest(df, cols)
df |
A dataframe containing the data to be tested. |
cols |
A vector of column names in the dataframe to be tested for normality. |
The function first reshapes the dataframe to a long format and calculates the sample size for each variable. It then checks if the sample size for any variable is less than 3 or greater than 5000, and if so, aborts the function with an error message because the 'shapiro.test()' only expects this range of observations. The function then performs the Shapiro-Wilk test on each variable and returns a formatted dataframe with the test results.
A dataframe with the test results. Each row corresponds to a variable, and the columns contain the test statistics and p-values.
[ntest_by()] to run normality tests for grouped data
## Not run:
# Perform multiple normality tests at once
ntest(df = mtcars,
cols = mpg)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.