JoonGi
2011-Mar-01 10:41 UTC
[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.
Mike Marchywka
2011-Mar-01 11:47 UTC
[R] Is there any Command showing correlation of all variables in a dataset?
----------------------------------------> Date: Tue, 1 Mar 2011 02:41:00 -0800 > From: joongi at hanmail.net > To: r-help at 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? >This appears to work as expected although I don't have enough intuition to know if these numbers are plausible beyond rough guess( diag of course is one LOL),> df<-data.frame(a=rnorm(100), b=runif(100),c=runif(100)+rnorm(100)) > str(df)'data.frame':?? 100 obs. of? 3 variables: ?$ a: num? 0.1841 0.2296 -1.2251 0.0898 -0.961 ... ?$ b: num? 0.586 0.343 0.821 0.41 0.352 ... ?$ c: num? -0.373 2.225 0.102 1.186 -0.737 ...> cor(df)?????????? a?????????? b?????????? c a 1.00000000? 0.07710107? 0.11088579 b 0.07710107? 1.00000000 -0.02424471 c 0.11088579 -0.02424471? 1.00000000> ?cor> df<-data.frame(a=.1*rnorm(100), b=(1:100)/100,c=(1:100)/100+.1*rnorm(100)) > cor(df)???????????? a?????????? b??????????? c a? 1.000000000 -0.01970874 -0.003665239 b -0.019708737? 1.00000000? 0.950375445 c -0.003665239? 0.95037544? 1.000000000>
rex.dwyer at syngenta.com
2011-Mar-01 15:54 UTC
[R] Is there any Command showing correlation of all variables in a dataset?
?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-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of JoonGi Sent: Tuesday, March 01, 2011 5:41 AM To: r-help at 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 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. 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.
Liviu Andronic
2011-Mar-01 17:11 UTC
[R] Is there any Command showing correlation of all variables in a dataset?
On Tue, Mar 1, 2011 at 11:41 AM, JoonGi <joongi at hanmail.net> wrote:> > 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? >See Rcmdr for an example. Liviu> > -- > 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 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. >-- Do you know how to read? http://www.alienetworks.com/srtest.cfm http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader Do you know how to write? http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail