[Rd] Bug in xy.coords() or documentation error?
Gavin Simpson
gavin.simpson at ucl.ac.uk
Sat Jan 21 19:21:52 CET 2006
On Sat, 2006-01-21 at 13:12 -0500, Gabor Grothendieck wrote:
> This was discussed just recently. This is a design
> error but the maintainers claim there are no cases of
> interest where it matters.
Thanks Gabor,
I must have missed that discussion whilst I was on vacation. If what you
say was the outcome of that discussion, it still means that the
documentation for xy.coords is in error, as you may *not* provide a
single argument 'x'.
If the intention is to keep the current behaviour - which is fine - then
the documentation should be changed, perhaps along the lines of:
x, y: the x and y coordinates of a set of points. Alternatively, a
single object 'x' can be provided if 'y = NULL' is also
supplied.
'object' might not be correct here - is a formula an 'object'?
Cheers,
Gav
>
> On 1/21/06, Gavin Simpson <gavin.simpson at ucl.ac.uk> wrote:
> > Hi,
> >
> > I noticed the following problem with xy.coords() in R 2.2.1-patched
> > (version info at the foot of this email) and R 2.3.0 unstable
> > (subversion no: r37123):
> >
> > > xy.coords(x = matrix(1:20, ncol = 2))
> > Error in xy.coords(x = matrix(1:20, ncol = 2)) :
> > argument "y" is missing, with no default
> > > xy.coords(x = matrix(1:20, ncol = 2), y = NULL)
> > $x
> > [1] 1 2 3 4 5 6 7 8 9 10
> >
> > $y
> > [1] 11 12 13 14 15 16 17 18 19 20
> >
> > $xlab
> > [1] "[,1]"
> >
> > $ylab
> > [1] "[,2]"
> >
> > And:
> >
> > > xy.coords(x = data.frame(x = 1:10, y = 1:10))
> > Error in xy.coords(x = data.frame(x = 1:10, y = 1:10)) :
> > argument "y" is missing, with no default
> > > xy.coords(x = data.frame(x = 1:10, y = 1:10), y = NULL)
> > $x
> > [1] 1 2 3 4 5 6 7 8 9 10
> >
> > $y
> > [1] 1 2 3 4 5 6 7 8 9 10
> >
> > $xlab
> > [1] "x"
> >
> > $ylab
> > [1] "y"
> >
> > ... for example.
> >
> > ?xy.coords states:
> >
> > x, y: the x and y coordinates of a set of points. Alternatively, a
> > single argument 'x' can be provided.
> >
> > Given that, I would have thought the above examples would have worked
> > without explicitly passing y = NULL to xy.coords(). However, ?xy,coords
> > later states:
> >
> > If 'y' is 'NULL' and 'x' is a
> >
> > and the examples all illustrate the use of NULL passed as y.
> >
> > Is this a documentation error and a single argument x is not allowed, or
> > is this a bug in the code? Either way, ?xy.coords contradicts itself as
> > one would expect to be able to pass only x given the statement above.
> >
> > If this is a bug in the code, a potential workaround appears to be to
> > change the first line of xy.coords from:
> >
> > if (is.null(y)) {
> >
> > to
> >
> > if (missing(y) || is.null(y)) {
> >
> > but I haven't tested this on anything other than my two examples.
> >
> > I will file a bug report if my observation is correct - but given all
> > the erroneous bug reports lately, I thought I'd try my luck here where
> > an error on my part would not cause the maintainers of the bug tracker
> > any extra work.
> >
> > > version
> > _
> > platform i686-pc-linux-gnu
> > arch i686
> > os linux-gnu
> > system i686, linux-gnu
> > status Patched
> > major 2
> > minor 2.1
> > year 2006
> > month 01
> > day 18
> > svn rev 37123
> > language R
> > > sessionInfo()
> > R version 2.2.1, 2006-01-18, i686-pc-linux-gnu
> >
> > attached base packages:
> > [1] "methods" "stats" "graphics" "grDevices"
> > [5] "utils" "datasets" "base"
> >
> > All the best,
> >
> > Gav
> >
> > --
> > %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
> > Gavin Simpson [T] +44 (0)20 7679 5522
> > ENSIS Research Fellow [F] +44 (0)20 7679 7565
> > ENSIS Ltd. & ECRC [E] gavin.simpsonATNOSPAMucl.ac.uk
> > UCL Department of Geography [W] http://www.ucl.ac.uk/~ucfagls/cv/
> > 26 Bedford Way [W] http://www.ucl.ac.uk/~ucfagls/
> > London. WC1H 0AP.
> > %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
> >
> > ______________________________________________
> > R-devel at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson [T] +44 (0)20 7679 5522
ENSIS Research Fellow [F] +44 (0)20 7679 7565
ENSIS Ltd. & ECRC [E] gavin.simpsonATNOSPAMucl.ac.uk
UCL Department of Geography [W] http://www.ucl.ac.uk/~ucfagls/cv/
26 Bedford Way [W] http://www.ucl.ac.uk/~ucfagls/
London. WC1H 0AP.
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-devel
mailing list