[Rd] NA as names of vector from subscripted matrix == bug ?
Thomas Lumley
tlumley@u.washington.edu
Mon, 8 Oct 2001 10:50:58 -0700 (PDT)
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._