From tlumley@u.washington.edu  Mon Oct  8 18:50:58 2001
From: tlumley@u.washington.edu (Thomas Lumley)
Date: Mon, 8 Oct 2001 10:50:58 -0700 (PDT)
Subject: [Rd] NA as names of vector from subscripted matrix == bug ?
In-Reply-To: <Pine.GSO.4.05.10110081028170.7117-100000@tajo.ucsd.edu>
Message-ID: <Pine.A41.4.33.0110081045290.91106-100000@homer08.u.washington.edu>

On Mon, 8 Oct 2001, Charles C. Berry wrote:
>
> Is this a bug?
>
> > matrix(1:4,nc=2,dimnames=list(1:2,1:2))[c(1,3)]
>  1 NA
>  1  3


Perhaps a clearer example is
> matrix(1:4,nc=2,dimnames=list(LETTERS[1:2],LETTERS[3:4]))->a
> a[1]
A
1
> a[2]
B
2
> a[3]
NA
 3
> a[4]
NA
 4
>

It's at least a wart that you sometimes get the row names and sometimes
NA.  OTOH it's not clear what the names of a vector extracted from a
matrix *should* be if the vector isn't a single row or column.



	-thomas


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


[Rd] NA as names of vector from subscripted matrix == bug ?
Thomas Lumley