Skip to content
Back to formatted view

Raw Message

Message-ID: <16110.62351.704257.863527@asteridia.maths.uwa.edu.au>
Date: 2003-06-17T10:55:11Z
From: Adrian Baddeley
Subject: plot.formula
In-Reply-To: <200306171008.h5HA6q4a015742@stat.math.ethz.ch>

Thanks to Andy Liaw and Baz 
for alternatives to tinkering with plot.formula
to get
	plot(cbind(y1,y2) ~ x, ...)
to work.

However...

   > From: "Liaw, Andy" <andy_liaw at merck.com>
    matplot(x, cbind(y1, y2), ...)

   > From: Barry Rowlingson <B.Rowlingson at lancaster.ac.uk>
   xyplot(y1+y2~x,data=xyy,allow.multiple=T)

The former requires separate code for the case of multiple response variables.

The latter does provide a formula interface, but the interpretation
of the formulae is inconvenient. 
For example

   - if y1 is an expression containing "+"
      then it would have to be protected by I() to prevent the 
      summands in the expression being plotted separately.
      
   - you can't replace one of the response variables by a constant, 
   as this will be evaluated as a vector of length 1.

It's a lot easier with cbind() , for example

     plot(cbind(z1 -zhat + bias, 0) ~ x)

gets you a plot of (z1-zhat+bias) versus x 
together with a horizontal line at y=0. 

The idea of using cbind() was indeed modelled on the glm() usage.

----
Adrian Baddeley, Mathematics & Statistics, University of Western Australia
		<http://maths.uwa.edu.au/~adrian/>