Last data update: 2014.03.03

R: cor.matrix
cor.matrixR Documentation

cor.matrix

Description

Creates a correlation matrix

Usage

cor.matrix(variables,with.variables,data=NULL,test=cor.test,...)

Arguments

variables

variables

with.variables

An optional set of variables to correlate with variables. If nothing is specified, all variables in variables are correlated with themselves.

data

A data.frame from which the variables and factor will be selected.

test

A function whose first two arguments are the variables upon which the correlation will be calculated, and whose result is an object of class htest.

...

further arguments for test.

Value

A multi.test object, representing a table of the results of func applied to each of the variables.

See Also

cor.test as.matrix.cor.matrix

Examples

dat<-data.frame(aa=rnorm(100),bb=rnorm(100),cc=rnorm(100),dd=rnorm(100))
dat$aa<-dat$aa+dat$dd
dat$cc<-dat$cc+dat$aa
cor.matrix(dat,test=cor.test)
cor.matrix(d(aa,cc),data=dat,test=cor.test,method="kendall")
cor.matrix(d(aa,cc),d(dd,bb),data=dat,test=cor.test,method="spearman")

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(Deducer)
Loading required package: ggplot2
Loading required package: JGR
Loading required package: rJava
Loading required package: JavaGD
Loading required package: iplots

Please type JGR() to launch console. Platform specific launchers (.exe and .app) can also be obtained at http://www.rforge.net/JGR/files/.


Loading required package: car
Loading required package: MASS


Note Non-JGR console detected:
	Deducer is best used from within JGR (http://jgr.markushelbig.org/).
	To Bring up GUI dialogs, type deducer().

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Deducer/cor.matrix.Rd_%03d_medium.png", width=480, height=480)
> ### Name: cor.matrix
> ### Title: cor.matrix
> ### Aliases: cor.matrix
> 
> ### ** Examples
> 
> dat<-data.frame(aa=rnorm(100),bb=rnorm(100),cc=rnorm(100),dd=rnorm(100))
> dat$aa<-dat$aa+dat$dd
> dat$cc<-dat$cc+dat$aa
> cor.matrix(dat,test=cor.test)

                       Pearson's product-moment correlation                       

          aa                bb                cc               
aa    cor 1                 -0.1007           0.8376           
        N 100               100               100              
      CI*                   (-0.2914,0.09763) (0.7674,0.8879)  
   stat**                   -1.002 (98)       15.18 (98)       
  p-value                   0.3187            0.0000           
---------                                                      
bb    cor -0.1007           1                 -0.1053          
        N 100               100               100              
      CI* (-0.2914,0.09763)                   (-0.2956,0.09301)
   stat** -1.002 (98)                         -1.049 (98)      
  p-value 0.3187                              0.2970           
---------                                                      
cc    cor 0.8376            -0.1053           1                
        N 100               100               100              
      CI* (0.7674,0.8879)   (-0.2956,0.09301)                  
   stat** 15.18 (98)        -1.049 (98)                        
  p-value 0.0000            0.2970                             
---------                                                      
dd    cor 0.7588            -0.1087           0.6004           
        N 100               100               100              
      CI* (0.6609,0.8314)   (-0.2988,0.08958) (0.458,0.7127)   
   stat** 11.53 (98)        -1.083 (98)       7.432 (98)       
  p-value 0.0000            0.2815            0.0000           
---------                                                      
          dd               
aa    cor 0.7588           
        N 100              
      CI* (0.6609,0.8314)  
   stat** 11.53 (98)       
  p-value 0.0000           
---------                  
bb    cor -0.1087          
        N 100              
      CI* (-0.2988,0.08958)
   stat** -1.083 (98)      
  p-value 0.2815           
---------                  
cc    cor 0.6004           
        N 100              
      CI* (0.458,0.7127)   
   stat** 7.432 (98)       
  p-value 0.0000           
---------                  
dd    cor 1                
        N 100              
      CI*                  
   stat**                  
  p-value                  
---------                  
	** t (df)
	 * 95% percent interval

	HA: two.sided 

> cor.matrix(d(aa,cc),data=dat,test=cor.test,method="kendall")

                          Kendall's rank correlation tau                          

          aa     cc    
aa    cor 1      0.6283
        N 100    100   
   stat**        9.262 
  p-value        0.0000
---------              
cc    cor 0.6283 1     
        N 100    100   
   stat** 9.262        
  p-value 0.0000       
---------              
	** z
	HA: two.sided 

> cor.matrix(d(aa,cc),d(dd,bb),data=dat,test=cor.test,method="spearman")

                         Spearman's rank correlation rho                          

          aa      cc     
dd    cor 0.7551  0.5693 
        N 100     100    
   stat** 40810   71778  
  p-value 0.0000  0.0000 
---------                
bb    cor -0.1149 -0.1077
        N 100     100    
   stat** 185794  184598 
  p-value 0.2546  0.2857 
---------                
	** S
	HA: two.sided 

> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>