I'm resending this after a decent interval of 20 days -- any
opinions? Should I file it as a bug report? Is it my mistake?
cheers
Ben Bolker
-------- Original Message --------
Subject: buglet (?) in de.restore()
Date: Tue, 21 Aug 2007 13:29:33 -0400
From: Ben Bolker <bolker at zoo.ufl.edu>
To: r-devel at r-project.org
If one calls data.entry() with a matrix:
A = matrix(0,2,2)
data.entry(A)
everything works fine except that it triggers a warning:
Warning message:
the condition has length > 1 and only the first element will be used in:
if (dim(x) == dim(args[[i]])) rn <- dimnames(args[[i]])[[1]] else rn
<- NULL
This is triggered by the following lines in de.restore() [in
src/library/utils/R/de.R]:> if( dim(x) == dim(args[[i]]) )
> rn <- dimnames(args[[i]])[[1]]
> else rn <- NULL
It would seem to make sense to replace the condition with
if (nrow(x) == nrow(args[[i]]))
(de.restore() is only called if an element of the list passed to
data.entry
has more than one column)
On a side note, I'm curious why
> > A = matrix(0,2,2)
> > is.vector(A)
> [1] FALSE
> > is(A,"vector")
> [1] TRUE
...
------------------
sessionInfo()
R version 2.5.1 (2007-06-27)
i486-pc-linux-gnu
locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C
attached base packages:
[1] "stats" "graphics" "grDevices"
"utils" "datasets" "methods"
[7] "base"
Ben Bolker wrote:> I'm resending this after a decent interval of 20 days -- any > opinions? Should I file it as a bug report? Is it my mistake? >It just slipped through the cracks, I suppose. I think it looks like a buglet -- the [[1]] in dimnames(args[[i]])[[1]] doesn't make sense unless dim(args[[i]]) is nonscalar. The suggested fix should be neutral since nrow(x)==dim(x)[1] by definition. I've fixed it now, but in principle it is the kind of material that bug reports are made of. -p> cheers > Ben Bolker > > > -------- Original Message -------- > Subject: buglet (?) in de.restore() > Date: Tue, 21 Aug 2007 13:29:33 -0400 > From: Ben Bolker <bolker at zoo.ufl.edu> > To: r-devel at r-project.org > > > > If one calls data.entry() with a matrix: > > A = matrix(0,2,2) > data.entry(A) > > everything works fine except that it triggers a warning: > > Warning message: > the condition has length > 1 and only the first element will be used in: > if (dim(x) == dim(args[[i]])) rn <- dimnames(args[[i]])[[1]] else rn > <- NULL > > This is triggered by the following lines in de.restore() [in > src/library/utils/R/de.R]: > >> if( dim(x) == dim(args[[i]]) ) >> rn <- dimnames(args[[i]])[[1]] >> else rn <- NULL >> > It would seem to make sense to replace the condition with > > if (nrow(x) == nrow(args[[i]])) > > (de.restore() is only called if an element of the list passed to > data.entry > has more than one column) > > On a side note, I'm curious why > > >>> A = matrix(0,2,2) >>> is.vector(A) >>> >> [1] FALSE >> >>> is(A,"vector") >>> >> [1] TRUE >> > ... > > ------------------ > sessionInfo() > R version 2.5.1 (2007-06-27) > i486-pc-linux-gnu > > locale: > LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C > > attached base packages: > [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" > [7] "base" > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >-- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
On 9/10/2007 8:47 AM, Ben Bolker wrote:> I'm resending this after a decent interval of 20 days -- any > opinions? Should I file it as a bug report? Is it my mistake?I think a bug report is in order.> > cheers > Ben Bolker > > > -------- Original Message -------- > Subject: buglet (?) in de.restore() > Date: Tue, 21 Aug 2007 13:29:33 -0400 > From: Ben Bolker <bolker at zoo.ufl.edu> > To: r-devel at r-project.org > > > > If one calls data.entry() with a matrix: > > A = matrix(0,2,2) > data.entry(A) > > everything works fine except that it triggers a warning: > > Warning message: > the condition has length > 1 and only the first element will be used in: > if (dim(x) == dim(args[[i]])) rn <- dimnames(args[[i]])[[1]] else rn > <- NULL > > This is triggered by the following lines in de.restore() [in > src/library/utils/R/de.R]: >> if( dim(x) == dim(args[[i]]) ) >> rn <- dimnames(args[[i]])[[1]] >> else rn <- NULL > It would seem to make sense to replace the condition with > > if (nrow(x) == nrow(args[[i]])) > > (de.restore() is only called if an element of the list passed to > data.entry > has more than one column) > > On a side note, I'm curious why > >> > A = matrix(0,2,2) >> > is.vector(A) >> [1] FALSE >> > is(A,"vector") >> [1] TRUEThe glib answer for the first result is that it's because it's documented that way. I guess it's so that you can distinguish simple vectors from matrices or other more complex objects. As to the second, you're testing whether A inherits from the class "vector", i.e. indexing works on it. Most things in R inherit from class vector, so that comes out TRUE. (Things that don't: NULL, environments, some other special stuff.) Duncan Murdoch