Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
How to perform shapiro test for all columns in an R data frame?
The shapiro test is used to test for the normality of variables and the null hypothesis for this test is the variable is normally distributed. If we have numerical columns in an R data frame then we might to check the normality of all the variables. This can be done with the help of apply function and shapiro.test as shown in the below example.
Example
apply(df,2,shapiro.test)
Output
$x1 Shapiro-Wilk normality test data: newX[, i] W = 0.94053, p-value = 0.2453 $x2 Shapiro-Wilk normality test data: newX[, i] W = 0.95223, p-value = 0.4022 $x3 Shapiro-Wilk normality test data: newX[, i] W = 0.88855, p-value = 0.02529 $x4 Shapiro-Wilk normality test data: newX[, i] W = 0.96244, p-value = 0.5938 $x5 Shapiro-Wilk normality test data: newX[, i] W = 0.87904, p-value = 0.017 $x6 Shapiro-Wilk normality test data: newX[, i] W = 0.93067, p-value = 0.1591 $x7 Shapiro-Wilk normality test data: newX[, i] W = 0.88531, p-value = 0.02208 $x8 Shapiro-Wilk normality test data: newX[, i] W = 0.96271, p-value = 0.5992
Advertisements
