From christos.hatzis at nuverabio.com  Tue Nov 11 19:47:03 2008
From: christos.hatzis at nuverabio.com (Christos Hatzis)
Date: Tue, 11 Nov 2008 13:47:03 -0500
Subject: [Rd] is.matrix
In-Reply-To: <4919CF75.3010202@biostat.ku.dk>
References: <d8858f220811111020j233d4d98j502c0079ace644e7@mail.gmail.com>
	<4919CF75.3010202@biostat.ku.dk>
Message-ID: <EBB1776B97F24F8D9A2556B50B43A541@headquarters.silicoinsights>

And the other missing piece is that t() coerces the input vector to a
1-column matrix that can then be transposed and returned as a 1-row matrix
(with a dim attribute).

-Christos

> -----Original Message-----
> From: r-devel-bounces at r-project.org 
> [mailto:r-devel-bounces at r-project.org] On Behalf Of Peter Dalgaard
> Sent: Tuesday, November 11, 2008 1:31 PM
> To: Daniel H?yer Iversen
> Cc: r-devel at r-project.org
> Subject: Re: [Rd] is.matrix
> 
> Daniel H?yer Iversen wrote:
> > a=c(1,1,2);
> > is.matrix(a) gives FALSE
> > is.matrix(t(a)) gives TRUE
> > is.matrix(t(t(a))) gives TRUE
> > 
> > Is this correct? Shouldn't all give FALSE?
> > I think is.matrix should give FALSE when dimension is 1*n or n*1.
> 
> No this is correct. is.matrix() returns TRUE if and only if 
> the argument has a two-dimensional 'dim' attribute, and
> 
>  > dim(a)
> NULL
> > dim(t(a))
> [1] 1 3
> > dim(t(t(a)))
> [1] 3 1
> 
> (And is.array() depends on having a 'dim' attribute of 
> positive length, so
> 
> > dim(a) <- 3
> > is.matrix(a)
> [1] FALSE
> > is.array(a)
> [1] TRUE
> 
> )
> 
> 
> -- 
>    O__  ---- Peter Dalgaard             ?ster Farimagsgade 5, Entr.B
>   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
>  (*) \(*) -- University of Copenhagen   Denmark      Ph:  
> (+45) 35327918
> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: 
> (+45) 35327907
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 



[Rd] is.matrix
Christos Hatzis