Created
September 14, 2017 15:42
-
-
Save arcaravaggi/004979408be4116505a49bd1d4c6e298 to your computer and use it in GitHub Desktop.
Function for pairwise correlations across a data frame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# E.g. qDat.corr <- as.data.frame(cor.test.p(x)) | |
cor.test.p <- function(x){ | |
FUN <- function(x, y) cor.test(x, y)[["p.value"]] | |
z <- outer( | |
colnames(x), | |
colnames(x), | |
Vectorize(function(i,j) FUN(x[,i], x[,j])) | |
) | |
dimnames(z) <- list(colnames(x), colnames(x)) | |
z | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment