R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-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. > x <- array(list(210907 + ,79 + ,30 + ,94 + ,112285 + ,144 + ,145 + ,120982 + ,58 + ,28 + ,103 + ,84786 + ,103 + ,101 + ,176508 + ,60 + ,38 + ,93 + ,83123 + ,98 + ,98 + ,179321 + ,108 + ,30 + ,103 + ,101193 + ,135 + ,132 + ,123185 + ,49 + ,22 + ,51 + ,38361 + ,61 + ,60 + ,52746 + ,0 + ,26 + ,70 + ,68504 + ,39 + ,38 + ,385534 + ,121 + ,25 + ,91 + ,119182 + ,150 + ,144 + ,33170 + ,1 + ,18 + ,22 + ,22807 + ,5 + ,5 + ,101645 + ,20 + ,11 + ,38 + ,17140 + ,28 + ,28 + ,149061 + ,43 + ,26 + ,93 + ,116174 + ,84 + ,84 + ,165446 + ,69 + ,25 + ,60 + ,57635 + ,80 + ,79 + ,237213 + ,78 + ,38 + ,123 + ,66198 + ,130 + ,127 + ,173326 + ,86 + ,44 + ,148 + ,71701 + ,82 + ,78 + ,133131 + ,44 + ,30 + ,90 + ,57793 + ,60 + ,60 + ,258873 + ,104 + ,40 + ,124 + ,80444 + ,131 + ,131 + ,180083 + ,63 + ,34 + ,70 + ,53855 + ,84 + ,84 + ,324799 + ,158 + ,47 + ,168 + ,97668 + ,140 + ,133 + ,230964 + ,102 + ,30 + ,115 + ,133824 + ,151 + ,150 + ,236785 + ,77 + ,31 + ,71 + ,101481 + ,91 + ,91 + ,135473 + ,82 + ,23 + ,66 + ,99645 + ,138 + ,132 + ,202925 + ,115 + ,36 + ,134 + ,114789 + ,150 + ,136 + ,215147 + ,101 + ,36 + ,117 + ,99052 + ,124 + ,124 + ,344297 + ,80 + ,30 + ,108 + ,67654 + ,119 + ,118 + ,153935 + ,50 + ,25 + ,84 + ,65553 + ,73 + ,70 + ,132943 + ,83 + ,39 + ,156 + ,97500 + ,110 + ,107 + ,174724 + ,123 + ,34 + ,120 + ,69112 + ,123 + ,119 + ,174415 + ,73 + ,31 + ,114 + ,82753 + ,90 + ,89 + ,225548 + ,81 + ,31 + ,94 + ,85323 + ,116 + ,112 + ,223632 + ,105 + ,33 + ,120 + ,72654 + ,113 + ,108 + ,124817 + ,47 + ,25 + ,81 + ,30727 + ,56 + ,52 + ,221698 + ,105 + ,33 + ,110 + ,77873 + ,115 + ,112 + ,210767 + ,94 + ,35 + ,133 + ,117478 + ,119 + ,116 + ,170266 + ,44 + ,42 + ,122 + ,74007 + ,129 + ,123 + ,260561 + ,114 + ,43 + ,158 + ,90183 + ,127 + ,125 + ,84853 + ,38 + ,30 + ,109 + ,61542 + ,27 + ,27 + ,294424 + ,107 + ,33 + ,124 + ,101494 + ,175 + ,162 + ,101011 + ,30 + ,13 + ,39 + ,27570 + ,35 + ,32 + ,215641 + ,71 + ,32 + ,92 + ,55813 + ,64 + ,64 + ,325107 + ,84 + ,36 + ,126 + ,79215 + ,96 + ,92 + ,7176 + ,0 + ,0 + ,0 + ,1423 + ,0 + ,0 + ,167542 + ,59 + ,28 + ,70 + ,55461 + ,84 + ,83 + ,106408 + ,33 + ,14 + ,37 + ,31081 + ,41 + ,41 + ,96560 + ,42 + ,17 + ,38 + ,22996 + ,47 + ,47 + ,265769 + ,96 + ,32 + ,120 + ,83122 + ,126 + ,120 + ,269651 + ,106 + ,30 + ,93 + ,70106 + ,105 + ,105 + ,149112 + ,56 + ,35 + ,95 + ,60578 + ,80 + ,79 + ,175824 + ,57 + ,20 + ,77 + ,39992 + ,70 + ,65 + ,152871 + ,59 + ,28 + ,90 + ,79892 + ,73 + ,70) + ,dim=c(7 + ,48) + ,dimnames=list(c('Y' + ,'X1' + ,'X2' + ,'X3' + ,'X4' + ,'X5' + ,'X6') + ,1:48)) > y <- array(NA,dim=c(7,48),dimnames=list(c('Y','X1','X2','X3','X4','X5','X6'),1:48)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par1 = 'pearson' > main = 'Correlation Matrix' > panel.tau <- function(x, y, digits=2, prefix='', cex.cor) + { + usr <- par('usr'); on.exit(par(usr)) + par(usr = c(0, 1, 0, 1)) + rr <- cor.test(x, y, method=par1) + r <- round(rr$p.value,2) + txt <- format(c(r, 0.123456789), digits=digits)[1] + txt <- paste(prefix, txt, sep='') + if(missing(cex.cor)) cex <- 0.5/strwidth(txt) + text(0.5, 0.5, txt, cex = cex) + } > panel.hist <- function(x, ...) + { + usr <- par('usr'); on.exit(par(usr)) + par(usr = c(usr[1:2], 0, 1.5) ) + h <- hist(x, plot = FALSE) + breaks <- h$breaks; nB <- length(breaks) + y <- h$counts; y <- y/max(y) + rect(breaks[-nB], 0, breaks[-1], y, col='grey', ...) + } > postscript(file="/var/wessaorg/rcomp/tmp/1goz81324627087.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > pairs(t(y),diag.panel=panel.hist, upper.panel=panel.smooth, lower.panel=panel.tau, main=main) > dev.off() null device 1 > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/rcomp/createtable") > > n <- length(y[,1]) > n [1] 7 > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,paste('Correlations for all pairs of data series (method=',par1,')',sep=''),n+1,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,' ',header=TRUE) > for (i in 1:n) { + a<-table.element(a,dimnames(t(x))[[2]][i],header=TRUE) + } > a<-table.row.end(a) > for (i in 1:n) { + a<-table.row.start(a) + a<-table.element(a,dimnames(t(x))[[2]][i],header=TRUE) + for (j in 1:n) { + r <- cor.test(y[i,],y[j,],method=par1) + a<-table.element(a,round(r$estimate,3)) + } + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/29knp1324627087.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Correlations for all pairs of data series with p-values',4,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'pair',1,TRUE) > a<-table.element(a,'Pearson r',1,TRUE) > a<-table.element(a,'Spearman rho',1,TRUE) > a<-table.element(a,'Kendall tau',1,TRUE) > a<-table.row.end(a) > cor.test(y[1,],y[2,],method=par1) Pearson's product-moment correlation data: y[1, ] and y[2, ] t = 9.4288, df = 46, p-value = 2.554e-12 alternative hypothesis: true correlation is not equal to 0 95 percent confidence interval: 0.6858598 0.8905224 sample estimates: cor 0.8117947 > for (i in 1:(n-1)) + { + for (j in (i+1):n) + { + a<-table.row.start(a) + dum <- paste(dimnames(t(x))[[2]][i],';',dimnames(t(x))[[2]][j],sep='') + a<-table.element(a,dum,header=TRUE) + rp <- cor.test(y[i,],y[j,],method='pearson') + a<-table.element(a,round(rp$estimate,4)) + rs <- cor.test(y[i,],y[j,],method='spearman') + a<-table.element(a,round(rs$estimate,4)) + rk <- cor.test(y[i,],y[j,],method='kendall') + a<-table.element(a,round(rk$estimate,4)) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'p-value',header=T) + a<-table.element(a,paste('(',round(rp$p.value,4),')',sep='')) + a<-table.element(a,paste('(',round(rs$p.value,4),')',sep='')) + a<-table.element(a,paste('(',round(rk$p.value,4),')',sep='')) + a<-table.row.end(a) + } + } There were 40 warnings (use warnings() to see them) > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/3xk351324627087.tab") > > try(system("convert tmp/1goz81324627087.ps tmp/1goz81324627087.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.966 0.096 1.101