From christos.hatzis at nuverabio.com  Tue Nov 11 21:01:51 2008
From: christos.hatzis at nuverabio.com (Christos Hatzis)
Date: Tue, 11 Nov 2008 15:01:51 -0500
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: <B614FD7006A74D98936F1C74663E4369@headquarters.silicoinsights>

The point was that c(1, 1, 2) is not a matrix but a vector, two distinct
things in R.

> a <- c(1, 1, 2)
> class(a)
[1] "numeric"
> ta <- t(a)
> class(ta)
[1] "matrix"
> class(t(ta))
[1] "matrix"

The transpose operation is only defined for matrices, so if you insist to
apply it to a vector, it first needs to be coersed to a matrix and then
transposed.  The result of this operation is a matrix. The result of
transposing this matrix will still be a matrix.

-Christos 

> -----Original Message-----
> From: r-devel-bounces at r-project.org 
> [mailto:r-devel-bounces at r-project.org] On Behalf Of Daniel 
> H?yer Iversen
> Sent: Tuesday, November 11, 2008 2:36 PM
> To: hadley wickham
> Cc: Tony Plate; r-devel at r-project.org
> Subject: Re: [Rd] is.matrix
> 
> > 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,
> 
> 
> 
> Daniel
> 
> 
> 
> On Tue, Nov 11, 2008 at 8:21 PM, hadley wickham 
> <h.wickham at gmail.com> wrote:
> >> |  is.matrix| returns |TRUE| if |x| is a matrix and has a |dim 
> >> | <dim.html>|
> >> attribute of length 2) and |FALSE| otherwise
> >
> > That's confusing!  In what situations is x a matrix but 
> does not have 
> > a dim attribute?
> >
> > Hadley
> >
> > --
> > http://had.co.nz/
> >
> >
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> 



[Rd] is.matrix
Christos Hatzis