This function is a wrapper around stats::shapiro.test(). It implements the Shapiro-Wilk test that tests the null hypothesis that a sample of values is a sample from a normal distribution. Thie function can be applied to single vectors or groups of vectors.

shapiro_test(y, by = NULL, data)

Arguments

y

A numeric variable whose normality is being tested.

by

An optional grouping variable

data

A data frame containing y and the by variable

Value

A tibble data frame with one row for each value of the by variable, or one row overall if there is no by variable. For the y variable whose normality is being tested, for each subset of values corresponding to the values of they by variable, or for all values if there is no by variable, return the Shapiro-Wilk statistic, and the corresponding p-value.

Examples

shapiro_test(faithful, data = faithfulfaces)
#> # A tibble: 1 × 2
#>   statistic p_value
#>       <dbl>   <dbl>
#> 1     0.981  0.0190
shapiro_test(faithful, by = face_sex, data = faithfulfaces)
#> # A tibble: 2 × 3
#>   face_sex statistic p_value
#>   <chr>        <dbl>   <dbl>
#> 1 female       0.972  0.0688
#> 2 male         0.979  0.168