[R] using panel functions in pairs()

Bill Shipley
Thu, 25 May 2006 18:20:03 -0000

Hello.  I want to construct a scatterplot matrix in which the above-diagonal
panels represent values from a control group while the below-diagonal values
represent values from a treatment group.  I have managed to write primative
panel functions (below) but cannot figure out how to pass arguments to these
panel functions.

Here is the panel function for the upper.panel argument of
pairs:
> my.upper.panel
function(x,y,treat.value=1,...)
{points(x[dat$treat==treat.value],y[dat$treat==treat.value],pch=16)}

Here is the panel function for the lower.panel agument of
pairs:
> my.lower.panel
function(x,y,treat.value=2,...)
{points(x[dat$treat==treat.value],y[dat$treat==treat.value],pch=1)}

Now, if I simply call: >
pairs(~x+y+z,data=dat,lower.panel=my.lower.panel,upper.panel=my.upper.panel)

I get what I want.  "dat" is a data frame with four columns called
"treat",
x, y, z and "treat" has values of 1 or 2.

I want to be able to specify the value of "treat.value" in my panel
functions within the call to pairs in cases in which the values of
"treat"
are different from 1 or 2.  Something like:

pairs(~x+y+z,data=dat,lower.panel=my.lower.panel(treat.value=2),upper.panelmy.upper.panel(treat.value=1))

However, when I do this, I get the error message:

>
pairs(~x+y+z,data=dat,lower.panel=my.lower.panel(treat.value=2),upper.panelmy.upper.panel(treat.value=1))
Error in points(x[dat$treat == treat.value], y[dat$treat == treat.value],  :

        argument "x" is missing, with no default

Question: how can one pass along different values of arguments from within a
panel function such as I have described?




Bill Shipley





	[[alternative HTML version deleted]]