[R] Defining range of x and y axis in pairs()
Christian Zinsmeister
kutchbhihosakatahai at yahoo.de
Tue Oct 18 20:22:16 CEST 2005
Hi,
I have a problem to define the range of x and y axis in pairs() for my
scatterplots. In low-level plots I can specify that by providing xlim
and ylim. This also works for pairs() even if warnings tell me that it
doesn't (see below).
But if I add upper.panel and/or lower.panel it doesn't work - I get an
error message saying that there's an error in "upper.panel
(as.vector(x[, j]), as.vector(x[, i]), ...)"!?
I know that (according to ?pairs) graphical parameters can be passed to
pairs() and xlim/ylim are *not* graphical parameters - I just wonder
why it anyway works in the first case.
Can anyway tell me how to adjust my pairs statement either using
xlim/ylim in a different way or by using totally different options?
(I'm a newbie to R)
# This works!
pairs(x, panel=points, xlim=c(-2,2));
# This one doesn't work
pairs(x, panel=points, xlim=c(-2,2), lower.panel=panel.cor,
upper.panel=panel.smooth);
# this is the function for lower.panel
panel.cor <- function(x, y)
{
usr <- par("usr"); on.exit(par(usr))
par(usr = c(0, 1, 0, 1))
txt <- cov(x, y, use="pairwise.complete.obs");
text(0.5, 0.5, txt);}
}
Thanks!
More information about the R-help
mailing list