[Rd] Inconsistent behaviour of is.vector? (PR#1052)
Peter Dalgaard BSA
14 Aug 2001 12:45:04 +0200
[R-bugs snipped from recipients]
> R appears to allow names as attributes but nothing else, but does not
> document this (except in the source code). Anyone want to explain why R
> is incompatible with S? And why as.vector and is.vector are inconsistent?
> (Note that the isas tests do not pick this up.)
It was discussed during 1997 and 1998... Ross, Thomas, Kurt, and
Martin seem to have been involved at some point. I'm not up to a full
reconstruction of the discussion just now, though. One of the earliest
cases is in this note from Thomas on the R-alpha mailing list:
On Mon, 7 Apr 1997, Ross Ihaka wrote:
> What should is.vector do?
> Essentially, everything in S is a vector unless it has attributes.
> This is utterly unreasonable! Why should something stop being a
> vector because it has a names attribute attached.
There is method to this. Something is a vector in S if as.vector() has
no effect on it. This includes functions but excludes matrices, vectors
with names, and data.frames. You might then ask why as.vector() works
the way it does and I would have no sensible explanation. A particularly
bizarre example is
i.e., the lm() function is a vector but the coefficient vector isn't.
There was also some discussion in December 1998, between Kurt and
Martin, but I cannot see how it got resolved.
(I seem to remember that we had as.vector retaining names for a while,
but got burned by package porting(?). Very early versions of R had
is.vector returning true for anything that could be subscripted,
BTW: My list archives seem to go further back than the "official"
ones. Do we want to do anything about that? Unfortunately they are in
Gnus's mail directory format and have been respooled so they are
slightly out of numerical order.
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (email@example.com) FAX: (+45) 35327907
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: firstname.lastname@example.org