cor.prob function gives matrix of correlation coefficients and p-values together
####### Function for calculating correlation matrix, corrs below diagonal, ####### and P-values above diagonal cor.prob <- function(X, dfr = nrow(X) - 2) { R <- cor(X) above <- row(R) < col(R) r2 <- R[above]^2 Fstat <- r2 * dfr / (1 - r2) R[above] <- 1 - pf(Fstat, 1, dfr) R } Scott On Tuesday, March 1, 2011 at 9:54 AM, rex.dw...@syngenta.com wrote: ?cor answers that question. If Housing is a dataframe, cor(Housing) should do it. Surprisingly, ??correlation doesn't point you to ?cor. > > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of JoonGi > Sent: Tuesday, March 01, 2011 5:41 AM > To: r-help@r-project.org > Subject: [R] Is there any Command showing correlation of all variables in a > dataset? > > > Thanks in advance. > > I want to derive correlations of variables in a dataset > > Specifically > > library(Ecdat) > data(Housing) > attach(Housing) > cor(lotsize, bathrooms) > > this code results only the correlationship between two variables. > But I want to examine all the combinations of variables in this dataset. > And I will finally make a table in Latex. > > How can I test correlations for all combinations of variables? > with one simple command? > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Is-there-any-Command-showing-correlation-of-all-variables-in-a-dataset-tp3329599p3329599.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. > > > > > message may contain confidential information. If you are not the designated > recipient, please notify the sender immediately, and delete the original and > any copies. Any use of the message by you is prohibited. > ______________________________________________ > 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. > [[alternative HTML version deleted]] ______________________________________________ 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.