Skip to content

Instantly share code, notes, and snippets.

@jclopeztavera
Last active March 8, 2017 07:19
Show Gist options
  • Save jclopeztavera/0d12c0bf1fff51d2814dc51c44fcf337 to your computer and use it in GitHub Desktop.
Save jclopeztavera/0d12c0bf1fff51d2814dc51c44fcf337 to your computer and use it in GitHub Desktop.
Function to test for normality of numeric variables in a dataframe
## Function to test for normality of numeric variables in a dataframe
is.normal <- function(x) {
z <- lapply(x[sapply(x, is.numeric)], shapiro.test)
lz <- length(z)
y <- logical(length = lz)
for (i in 1:lz) {
if (z[[i]]$p.value >= 0.1) {
y[i] <- TRUE
} else {
y[i] <- FALSE
}
}
return(y)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment