[R] function for nice correlation output with significance symbols

2009-05-10 Thread Martin Batholdy

hi,


I am searching for a nice function which computes correlations out of  
a data.frame and adds asterix-signs after each correlation when they  
are significant...


...or a function which just show correlations greater than x in the  
output.





thanks!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] function for nice correlation output with significance symbols

2009-05-10 Thread Chuck Cleland
On 5/10/2009 3:26 PM, Martin Batholdy wrote:
 hi,
 
 I am searching for a nice function which computes correlations out of a
 data.frame and adds asterix-signs after each correlation when they are
 significant...
 
 ...or a function which just show correlations greater than x in the output.
 
 thanks!

  This might be a starting point:

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.111, 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)
}

corstars(swiss[,1:4])

Fertility| Agriculture| Examination| Education|
Fertility 1.000  | 0.353* |-0.646**|  -0.664**|
Agriculture   0.353* | 1.000  |-0.687**|  -0.640**|
Examination  -0.646**|-0.687**| 1.000  |   0.698**|
Education-0.664**|-0.640**| 0.698**|   1.000  |

  At the very least, you could add a note that indicates what different
numbers of stars mean.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code. 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] function for nice correlation output with significance symbols

2009-05-10 Thread Andreas Christoffersen
Maybe pairs.panels(df,scale=T) from the psych library - se more here:
http://www.personality-project.org/r/html/00.psych-package.html

setting scale=T scales the cor coefficient according to their value. I
have seen an implementation with added asterix' but couldn't find it
right now.

On Sun, May 10, 2009 at 10:36 PM, Chuck Cleland cclel...@optonline.net wrote:
 On 5/10/2009 3:26 PM, Martin Batholdy wrote:
 hi,

 I am searching for a nice function which computes correlations out of a
 data.frame and adds asterix-signs after each correlation when they are
 significant...

 ...or a function which just show correlations greater than x in the output.

 thanks!


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.