Skip to content

Instantly share code, notes, and snippets.

@tukachev
Created December 7, 2013 02:00
Show Gist options
  • Save tukachev/7836436 to your computer and use it in GitHub Desktop.
Save tukachev/7836436 to your computer and use it in GitHub Desktop.
Функция corstars (метим значимые коэффиценты корреляции * )
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)
}
@lovakov
Copy link

lovakov commented Apr 11, 2015

Спасибо, супер!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment