Dimnamenames (PR#257)

About this list Date view Thread view Subject view Author view Other groups

Subject: Dimnamenames (PR#257)
p.dalgaard@biostat.ku.dk
Date: Thu 04 Nov 1999 - 01:56:25 EST


Message-Id: <199911031556.QAA23767@pubhealth.ku.dk>

I've just started digging into Andreas's old report:

> a <- array(0,c(2,2,2));
> dimnames(a)<-list(hansi=1:2, pepi=c("a","b"), karli=3:4)
> dimnames(a[,,1]) # losing component names
[[1]]
[1] "1" "2"

[[2]]
[1] "a" "b"

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? Generally, such 1-d arrays behave like vectors,
and noone has reported trouble with the fact that the result of table
can be a 1d array. From some viewpoints it seems odd to have different
behaviour depending on whether something is named or not, but it
*would* be nice to have the label retained on rows extracted from a
table...

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             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: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b25 : Tue 04 Jan 2000 - 14:16:09 EST