Provides a pipe-friendly framework to performs Shapiro-Wilk test of normality. Support grouped data and multiple variables for multivariate normality tests. Wrapper around the R base function shapiro.test(). Can handle grouped data. Read more: Normality Test in R.

shapiro_test(data, ..., vars = NULL)

mshapiro_test(data)

Arguments

data

a data frame. Columns are variables.

...

One or more unquoted expressions (or variable names) separated by commas. Used to select a variable of interest.

vars

optional character vector containing variable names. Ignored when dot vars are specified.

Value

a data frame containing the value of the Shapiro-Wilk statistic and the corresponding p.value.

Functions

  • shapiro_test(): univariate Shapiro-Wilk normality test

  • mshapiro_test(): multivariate Shapiro-Wilk normality test. This is a modified copy of the mshapiro.test() function of the package mvnormtest, for internal convenience.

Examples


# Shapiro Wilk normality test for one variable
iris %>% shapiro_test(Sepal.Length)
#> # A tibble: 1 × 3
#>   variable     statistic      p
#>   <chr>            <dbl>  <dbl>
#> 1 Sepal.Length     0.976 0.0102

# Shapiro Wilk normality test for two variables
iris %>% shapiro_test(Sepal.Length, Petal.Width)
#> # A tibble: 2 × 3
#>   variable     statistic            p
#>   <chr>            <dbl>        <dbl>
#> 1 Petal.Width      0.902 0.0000000168
#> 2 Sepal.Length     0.976 0.0102      

# Multivariate normality test
mshapiro_test(iris[, 1:3])
#> # A tibble: 1 × 2
#>   statistic p.value
#>       <dbl>   <dbl>
#> 1     0.991   0.443