[R] Defining range of x and y axis in pairs()

From: Christian Zinsmeister <kutchbhihosakatahai_at_yahoo.de>
Date: Wed 19 Oct 2005 - 04:22:16 EST


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!



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Oct 19 06:40:13 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:40:46 EST