[Rd] is.matrix
hadley wickham
h.wickham at gmail.com
Tue Nov 11 20:46:50 CET 2008
On Tue, Nov 11, 2008 at 1:35 PM, Daniel Høyer Iversen
<danielho at stud.ntnu.no> wrote:
>> That's confusing! In what situations is x a matrix but does not have
>> a dim attribute?
>
> That was my point. I don't find it logical that
> is.matrix(a) gives FALSE but
> is.matrix(t( t(a) )) gives TRUE.
>
> I also think it would be more logical that
> a=c(1,1,2)
> dim(a) gives 3 1 instead of NULL,
In R t(t(a)) != a, because a vector is different to a 1d matrix. This
is different to mathematical convention - you could argue that it
would have been wise to stick with convention, but there are some good
reasons for treating vectors differently to 1d matrices, and its too
late to change now.
Note that the following are all different in R:
a <- 1:3
b <- array(1:3, 3)
c <- array(1:3, c(3,1))
d <- array(1:3, c(3,1,1))
e <- array(1:3, c(3,1,1,1))
f <- array(1:3, c(3,1,1,1,1))
Hadley
--
http://had.co.nz/
More information about the R-devel
mailing list