From pgilbert@bank-banque-canada.ca  Wed Sep  9 15:46:54 1998
From: pgilbert@bank-banque-canada.ca (Paul Gilbert)
Date: Wed, 9 Sep 1998 10:46:54 -0400
Subject: diag() losing dimnames
Message-ID: <98Sep9.105903edt.13451@mailgate.bank-banque-canada.ca>

Using diag() to extract the diagonal of a matrix loses all but the first dimname
(R 0.62.3). The problem seems to be in [ ]:
>
> x <- matrix(1:9,3,3)
> dimnames(x) <- list(c("a", "b", "c"), c("a", "b", "c"))
> x
  a b c
a 1 4 7
b 2 5 8
c 3 6 9
> diag(x)
 a NA NA
 1  5  9
> x[c(1,5,9)]
 a NA NA
 1  5  9
>

Paul Gilbert

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


diag() losing dimnames
Paul Gilbert