Create Some Data

X is intentionally created as a Normally distributed random sample. Conversely, Y is created as a sample from the exponential distribution.

X <- rnorm(1000,100,10)
Y <- rexp(1000,10)

Histogram of X and Y

par(mfrow=c(1,2))
hist(X,breaks=100)
hist(Y,breaks=100)

par(mfrow=c(1,1))

The Shapiro-Wilk Test for Normality

shapiro.test(X)
## 
##  Shapiro-Wilk normality test
## 
## data:  X
## W = 0.99755, p-value = 0.1398
shapiro.test(Y)
## 
##  Shapiro-Wilk normality test
## 
## data:  Y
## W = 0.78877, p-value < 2.2e-16

{nortest}: Tests for Normality

Five omnibus tests for testing the composite hypothesis of norm

library(nortest)