[R] extension to plot.formula?

Barry Rowlingson B.Rowlingson at lancaster.ac.uk
Mon Jun 16 14:24:22 CEST 2003


Adrian Baddeley wrote:
> Could I suggest the following extension to plot.formula:
> 
>       plot(cbind(y1,y2) ~ x, ...)
> 
> should plot (y1 against x) and (y2 against x) on the same plot.
> 

  Trellis - er - lattice graphics uses a similar approach, but you use 
'+', and give another argument, allow.multiple:

xyplot(y1+y2~x,data=xyy,allow.multiple=T)

  I'm no great user of lattice graphics, so I leave it to someone else 
to tell us how to join the dots with lines.

  The cbind() approach has a precedent in glm(cbind(y,n)~x,family=binomial)

  Although I've always found plotting with formulas a bit ugly, since 
the 'x' and 'y' are in reverse alphabetic order and I could be plotting 
things that conceptually have no formulaic relationship - x and y 
geographic coordinates, for instance. In a modelling context you can 
read the ~ as 'depends on', but not necessarily in a plot!

Baz




More information about the R-help mailing list