Created
December 7, 2013 02:00
-
-
Save tukachev/7836436 to your computer and use it in GitHub Desktop.
Функция corstars (метим значимые коэффиценты корреляции * )
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
corstars < - function(x){ | |
require(Hmisc) | |
x <- as.matrix(x) | |
R <- rcorr(x)$r | |
p <- rcorr(x)$P | |
mystars <- ifelse(p < .01, "**|", ifelse(p < .05, "* |", " |")) | |
R <- format(round(cbind(rep(-1.11, ncol(x)), R), 3))[,-1] | |
Rnew <- matrix(paste(R, mystars, sep=""), ncol=ncol(x)) | |
diag(Rnew) <- paste(diag(R), " |", sep="") | |
rownames(Rnew) <- colnames(x) | |
colnames(Rnew) <- paste(colnames(x), "|", sep="") | |
Rnew <- as.data.frame(Rnew) | |
return(Rnew) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Спасибо, супер!