Dimnamenames (PR#257)

Jonathan Rougier Jonathan Rougier <J.C.Rougier@durham.ac.uk>
Wed, 3 Nov 1999 16:33:19 +0000 (GMT)

Hi Peter,

On Wed, 3 Nov 1999 p.dalgaard@biostat.ku.dk wrote:

> Now, this would be fairly easily fixed (I think) which would also make
> it compatible with S3. But what should one do about a[,1,1]?  This
> would generally be a vector with a .Names attribute, onto which there
> is no way of attaching a name. The obvious idea would be to force it
> to be a 1d array instead, i.e.
> structure(c(0,0), .Dim = 2, .Dimnames = structure(list(hansi=c("1","2")))) 
> rather than
> structure(c(0,0), .Names = c("1","2"))
> Does this sound safe?

I'm not sure.  Aren't you duplicating the functionality provided by the
drop flag?  After all, if the names were important then presumably the
subscription would have been a[,1,1, drop=FALSE] anyhow.  I like the
concept of a vector in this situation and suspect that in my lazy code I
have stuff that checks for a dim attribute whan checking arguments to
functions, which would be a problem.  Perhaps it would be better to pass
the name as a different attribute, eg

structure(c(0, 0), .Names = c("1","2"), .dnm = "hansi")

But it would be great to have the names fixed!

Cheers, Jonathan.

Jonathan Rougier                       Science Laboratories
Department of Mathematical Sciences    South Road
University of Durham                   Durham DH1 3LE

"[B]egin upon the precept ... that the things we see are to be 
 weighed in the scale with what we know"  (Meredith, 1879, The Egoist)

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: r-devel-request@stat.math.ethz.ch