From Waclaw.Marcin.Kusnierczyk at idi.ntnu.no  Tue Nov 11 20:55:04 2008
From: Waclaw.Marcin.Kusnierczyk at idi.ntnu.no (Wacek Kusnierczyk)
Date: Tue, 11 Nov 2008 20:55:04 +0100
Subject: [Rd] is.matrix
In-Reply-To: <d8858f220811111135s644fb759nc150c4094ca11398@mail.gmail.com>
References: <d8858f220811111020j233d4d98j502c0079ace644e7@mail.gmail.com>	<4919D240.4040904@acm.org>	<f8e6ff050811111121u62cc1329s605ca0dcd521dfb2@mail.gmail.com>
	<d8858f220811111135s644fb759nc150c4094ca11398@mail.gmail.com>
Message-ID: <4919E318.1010105@idi.ntnu.no>

Daniel H?yer Iversen 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.
>   
that's a different story, because t() performs an implicit cast from
vector to matrix, so you have

t(vector) -> matrix
t(matrix) -> matrix
t(t(vector)) -> matrix

interestingly,

x = 1:2
dim(x) = 2

adds "matrix" to is(x), but it is still not is.matrix(x) (consistently
with the docs).


> I also think it would be more logical that
> a=c(1,1,2)
> dim(a) gives 3 1 instead of NULL,
>   
well, it might give 3 1 1, or 3 1 1 1, or ..., which all could be
considered logical.
i think dim(x) giving just 3 would be fine.

vQ



[Rd] is.matrix
Wacek Kusnierczyk