[R] Scatter plots using pairs()
arun
smartpink111 at yahoo.com
Wed Feb 12 03:15:52 CET 2014
Did you run the panel.cor?
pairs(z,upper.panel=panel.cor)
Error in pairs.default(z, upper.panel = panel.cor) :
object 'panel.cor' not found
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 <- paste0(prefix, txt)
if(missing(cex.cor)) cex.cor <- 0.8/strwidth(txt)
text(0.5, 0.5, txt, cex = cex.cor * r)
}
pairs(z,upper.panel=panel.cor)
A.K.
On Tuesday, February 11, 2014 9:08 PM, Nestor Arguea <narguea at uwf.edu> wrote:
Command pairs() does not show the correlation coefficient on the upper
diagonal of a set of scatter plots. The command produces an error in
Windows 7, but it works fine in OS X Mavericks with the same R version
3.0.2. Platform, R version and example under Windows 7 provided
below.
$platform
[1] "i386-w64-mingw32"
...
$version.string
[1] "R version 3.0.2 (2013-09-25)"
Example:
> set.seed(12345)
> x <- rnorm(10)
> y <- log(c(2:11))
> z <- data.frame(x,y)
> cor(z)
x y
x 1.0000000 -0.4867929
y -0.4867929 1.0000000
> pairs(z)
> pairs(z,upper.panel=panel.cor)
Error in pairs.default(z, upper.panel = panel.cor) :
object 'panel.cor' not found
Thanks,
Nestor
--
Nestor Arguea
Chair, Marketing and Economics
Director of International Business Programs
University of West Florida
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list