Skip to content
Back to formatted view

Raw Message

Message-ID: <x2is8l6ddf.fsf@biostat.ku.dk>
Date: 2004-11-04T11:51:40Z
From: Peter Dalgaard
Subject: keep dimension of a sub matrix
In-Reply-To: <20041104110630.61210.qmail@web26403.mail.ukl.yahoo.com>

JC Vaugeois <vaugeoisjc at yahoo.fr> writes:

> Hi,
> is there any way to keep a sub matrix dimension?
>  
> exemple :
> i1<-1; i2<-1
> j1<-2; j2<-3;
> ret <-matrix(1,4,4)[i1:i2,j1:j2] ;
>  
> dim(ret) is NULL because the submatrix single col or single row is coerce to a vector automaticaly.
> How can i bypass this cast  : submatrix->vector   ???????

help("[") 

drop=FALSE is what you're looking for

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907