[R] Fancy pairs(), scatterplot matrix?

Ko-Kang Wang Ko-Kang at xtra.co.nz
Thu Jul 26 21:41:48 CEST 2001


I believe that you can find it by typing ?pairs in R, this is how I found it.  But anyway, here it is:

panel.cor <- function(x, y, digits=2, prefix="", cex.cor) {
    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 <- paste(prefix, txt, sep="")
    if(missing(cex.cor)) cex <- 0.8/strwidth(txt)
    text(0.5, 0.5, txt, cex = cex * r)
}
pairs( sport[c(1, 3:8 )], main = "Australian Institute of Sport Data - with Correlations",
       upper.panel=panel.smooth, lower.panel=panel.cor )

The panel.cor basically is the correlation function, which will be place in the "lower.panel" - a parameter in the pairs() function.  The upper.panel can be set to panel.smooth, which will have a smoothly fitted line in your plots.    You will need to put your dataset names in the place of sport though, as this is a case I just did which I copied the lines and pasted here.

Cheers,

Kevin


-------------------------------------------------------------------------------------------- 
Ko-Kang Kevin Wang
Head of Statistical Analysis Division
Software Developers' Klub (SDK)
University of Auckland
New Zealand

-----Original Message-----
From: owner-r-help at stat.math.ethz.ch [mailto:owner-r-help at stat.math.ethz.ch]On Behalf Of Martin Henry H. Stevens
Sent: Friday, July 27, 2001 6:23 AM
To: r-help at stat.math.ethz.ch
Subject: [R] Fancy pairs(), scatterplot matrix?


(I have checked the 2000 &2001 archives)
Awhile ago, someone posted a function to plot a scatterplot matrix with the
upper triangle containing plots (and maybe fitted curves?) and the lower
triangle containing the correlation coefs. I have lost that code and would
love it again if anyone has it. Thanks,
Henry
*****************************
Martin Henry H. Stevens
HStevens at muohio.edu
tel: (513) 529 - 4206
FAX: (513) 529 - 4243

338 Pearson Hall
Botany Department
Miami University
Oxford, OH 45056

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list