[R] panel.pairs in splom

ibrito isabel.brito at curie.fr
Thu Sep 30 17:11:33 CEST 2010


Hello,

I have a customized pairs () fonction as follows that displays correctely my
data.

------------------------------------------------------------------------
     panel.cor1 <- function (x, y, digits=2, prefix="")
     {
         usr <- par("usr"); on.exit(par(usr))
         par(usr = c(0, 1, 0, 1))
         r  <- cor(x, y,use="pairwise.complete.obs", method = meth)
           if (r>0) {alt<-"greater"
         } else      alt<-"less"
         co <-cor.test(x,y,method = meth,alternative=alt)$p.value
           if (co<0.05 ) {colo<-"red"
         } else           colo<-"black"
         txt <- format(c(r, 0.123456789), digits=digits)[1]
         txt <- paste(prefix, txt, sep="")
         cex.cor <- 0.8/strwidth(txt)
         text(0.5, 0.5, txt, cex = abs(cex.cor * r),col=colo)
       } 
    panel.line1 <- function (x, y, col = par("col"), bg = NA, pch =
par("pch"), cex = 1)
     {
         points(x, y, pch = pch, col = colour, bg = bg, cex = cex)
         ok <- is.finite(x) & is.finite(y)
         if (any(ok))
         abline(lsfit(x,y,intercept = TRUE), col= "red" )
     }
pairs(temp.df,
      lower.panel=panel.line1,upper.panel=panel.cor1 )
------------------------------------------------------------------------
However I decided to add a green line to my display and I was not able to do
it with the pairs() function, I used insted splom().
But I dont'know how to change panel.pairs inside superpanel in order to use
my panel.line1 and panel.cor1 functions.

------------------------------------------------------------------------
splom(~temp.df, aspect="fill", varnames=paste("coord", 1:10, sep=""),
      xlab="", pscales=0, varname.cex=0.6, cex=0.2,
      superpanel = function(...) {
          panel.pairs(...)
          panel.abline(h =6.5, v = 6.5, col = "green", lwd = 4)
      })
------------------------------------------------------------------------

I very much appreciate if someone could help me.

All the best,

Isabel

-- 
View this message in context: http://r.789695.n4.nabble.com/panel-pairs-in-splom-tp2720948p2720948.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list