Correlation Matrix in R
Alex, corr.test in psych will give you a matrix of correlations, a matrix of sample sizes, and a matrix of probabilities. You can combine the correlations and the probabilities to form what you want: try the following:
library(psych) examp <- corr.test(sat.act) mat.c.p <- lower.tri(examp$r)*examp$r + t(lower.tri(examp$p)*examp$p) mat.cp
Bill
On Oct 26, 2011, at 6:03 AM, AlexC wrote:
Thank you for your quick reply and helpful advice. Using this argument allows me to do what I needed to do Now the only other thing I wanted to accomplish was to obtain the top half of the matrix with p values and the bottom half with the correlations, to observe the significant correlations. I have been able to use a few functions such as rcorr, and cor.matrix to get such information but it isn't output in a format that I can save with the write.table function or write.clipboard the pair function allows a graphical display of the data on the other hand (with correlation graphics on the bottom half) and I have added an argument which allows to view the significant p values. But I wanted to know if I could also do the above easily. -- View this message in context: http://r.789695.n4.nabble.com/Correlation-Matrix-in-R-tp3938274p3940170.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ R-help at 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.
William Revelle http://personality-project.org/revelle.html Professor http://personality-project.org Department of Psychology http://www.wcas.northwestern.edu/psych/ Northwestern University http://www.northwestern.edu/ Use R for psychology http://personality-project.org/r It is 6 minutes to midnight http://www.thebulletin.org