[R] panel.pairs in splom
ibrito
isabel.brito at curie.fr
Thu Sep 30 17:39:27 CEST 2010
Indeed, some commands are missing. Sorry.
My function is as follows,
----------------------------------------------------------------------------------------
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" )
}
temp.df <- sapply(1:10, function(i) rnorm(20, 0,1))
meth<-"kendall"
colour<-c(rep("blue", 20 ))
pairs(temp.df,
lower.panel=panel.line1,upper.panel=panel.cor1 )
----------------------------------------------------------------------------------------
I would like to use panel.line1 and panel.cor1 inside superpanel of splom
function below
----------------------------------------------------------------------------------------
require(lattice)
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)
})
----------------------------------------------------------------------------------------
Best,
Isabel
--
View this message in context: http://r.789695.n4.nabble.com/panel-pairs-in-splom-tp2720948p2721009.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list