[R] variable labels in pairs
Christos Hatzis
christos at silicoinsights.com
Tue Apr 25 22:36:45 CEST 2006
Hello,
I am using 'pairs' to produce a scatter plot matrix with a custom
upper.panel function to plot the Pearson's correlation coefficients for the
pairs of variables.
I would like to be able to use the actual variable names as subscripts in
rho in the printed text. I know these labels are accessible to diag.panel
but cannot find a good way to access them within panel.cor.
Any suggestions?
Thank you.
-Christos
### --- code snip -----------
panel.cor <-
function(x, y, digits=3, subscripts, groups, cex.cor=2) {
usr <- par("usr"); on.exit(par(usr))
par(usr = c(0, 1, 0, 1))
r <- abs(cor(x, y))
txt <- format(c(r, 0.123456789), digits=digits)[1]
txt <- substitute(italic(rho) == txt)
text(0.5, 0.5, txt, cex = cex.cor, col="blue")
}
pairs(my.df, upper.panel=panel.cor)
More information about the R-help
mailing list