[Returnanalytics-commits] r2324 - pkg/PerformanceAnalytics/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Feb 16 16:31:39 CET 2013


Author: peter_carl
Date: 2013-02-16 16:31:39 +0100 (Sat, 16 Feb 2013)
New Revision: 2324

Modified:
   pkg/PerformanceAnalytics/R/chart.Correlation.R
Log:
- negative correlation values shown correctly
- cex buffered for small correlation values to keep them readable
- Thanks to Max Ghenis for the patch


Modified: pkg/PerformanceAnalytics/R/chart.Correlation.R
===================================================================
--- pkg/PerformanceAnalytics/R/chart.Correlation.R	2013-01-29 17:25:17 UTC (rev 2323)
+++ pkg/PerformanceAnalytics/R/chart.Correlation.R	2013-02-16 15:31:39 UTC (rev 2324)
@@ -41,7 +41,7 @@
     {
         usr <- par("usr"); on.exit(par(usr))
         par(usr = c(0, 1, 0, 1))
-        r <- abs(cor(x, y, use = use,method=method))
+        r <- cor(x, y, use=use, method=method) # MG: remove abs here
         txt <- format(c(r, 0.123456789), digits=digits)[1]
         txt <- paste(prefix, txt, sep="")
         if(missing(cex.cor)) cex <- 0.8/strwidth(txt)
@@ -51,8 +51,8 @@
         Signif <- symnum(test$p.value, corr = FALSE, na = FALSE,
                     cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1),
                     symbols = c("***", "**", "*", ".", " "))
-
-        text(0.5, 0.5, txt, cex = cex * r)
+        # MG: add abs here and also include a 30% buffer for small numbers
+        text(0.5, 0.5, txt, cex = cex * (abs(r) + .3) / 1.3)
         text(.8, .8, Signif, cex=cex, col=2)
     }
     f <- function(t) {
@@ -76,7 +76,7 @@
     if(histogram)
         pairs(x, gap=0, lower.panel=panel.smooth, upper.panel=panel.cor, diag.panel=hist.panel, method=method, ...)
     else
-        pairs(x, gap=0, lower.panel=panel.smooth, upper.panel=panel.cor, method=method, ...)
+        pairs(x, gap=0, lower.panel=panel.smooth, upper.panel=panel.cor, method=method, ...) 
 }
 
 ###############################################################################



More information about the Returnanalytics-commits mailing list