[R] adding p-value to a correlogram

Alon Ben-Ari alon.benari at gmail.com
Wed Jul 22 17:04:17 CEST 2009


Hello,

I am trying to plot a  correlogram and add the correlation coefficient
and p-value.
This is the code I am using :

pairs(d,
      gap = 0,
      lower.panel = panel.smooth,
      upper.panel = function (x,y) {
        panel.smooth(x,y)
        par(usr = c(0, 1, 0, 1))
        a <- cor(x,y,use="pairwise.complete.obs",method="spearman")
	a.p.value=cor.test(x,y,use="pairwise.complete.obs",method="kendall")

        text(.1,.9,
             adj=c(0,1),
             round(a, digits=2),
             col='blue',
             cex=2*a)
	text (0.9,0.9,round(a.p.value,digits=2),col='blue',cex=2*a.p.value)
      })

I get the error
In cor.test.default(x, y, use = "pairwise.complete.obs", method = "kendall") :
  Cannot compute exact p-value with ties
And it will not print the p-values. Any ideas how to work around this issue?

R:2.8
Linux openSUSE 11.1

Thanks,

Alon




More information about the R-help mailing list