From ggrothendieck at gmail.com  Sat Dec 31 14:57:43 2005
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Sat, 31 Dec 2005 08:57:43 -0500
Subject: [Rd] xy.coords
In-Reply-To: <43B68554.9030505@stats.uwo.ca>
References: <971536df0512301910k1e98e8e9pd4aa00149fedf1af@mail.gmail.com>
	<43B68554.9030505@stats.uwo.ca>
Message-ID: <971536df0512310557l1e3ea702ic9f4444b7583f4a7@mail.gmail.com>

It could be changed to missing(y) || is.null(y) and the docs amended.
That way existing code will continue to work and code that otherwise
gives an error currently, but should have worked, will now work too.

On 12/31/05, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
> On 12/30/2005 10:10 PM, Gabor Grothendieck wrote:
> > In ?xy.coords it says:
> >
> >      If 'y' is missing and 'x' is a
> >
> >      formula: of the form 'yvar ~ xvar'. 'xvar' and 'yvar' are used as
> >           x and y variables.
> >
> >      list: containing components 'x' and 'y', these are used to define
> >           plotting coordinates.
> >
> >      time series: the x values are taken to be 'time(x)' and the y
> >           values to be the time series.
> >
> >      matrix with two columns: the first is assumed to contain the x
> >           values and the second the y values.
> >
> > however, in fact, if y is missing an error is given. e.g.
> >
> > x <- 1:3
> > y <- 4:6
> > xy.coords(y ~ x) # error
> > xy.coords(cbind(x, y)) # error
> > xy.coords(ts(y)) # error
> >
> > Looking at the code, is.null(y) in the first line of the
> > body should be missing(y) .
>
> It would be better to change the docs to say "if 'y' is NULL ...".  The
> code has been the way it is for years and years, and is widely used.
>
> Changing the test to missing(y) would mean all existing uses that put a
> NULL there would need to be changed.
>
> Adding a default value of NULL to y would have less impact, but I'd
> still be worried about it having long-range bad effects.
>
> Duncan Murdoch
>



[Rd] xy.coords
Gabor Grothendieck