[R] keep dimension of a sub matrix

Dimitris Rizopoulos dimitris.rizopoulos at med.kuleuven.ac.be
Thu Nov 4 12:48:31 CET 2004

just use

matrix(1,4,4)[i1:i2,j1:j2, drop=FALSE]


Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/396887
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/

----- Original Message ----- 
From: "JC Vaugeois" <vaugeoisjc at yahoo.fr>
To: <R-help at stat.math.ethz.ch>
Sent: Thursday, November 04, 2004 12:06 PM
Subject: [R] keep dimension of a sub matrix

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   ???????

Thank you.


[[alternative HTML version deleted]]

R-help at stat.math.ethz.ch mailing list
PLEASE do read the posting guide! 

More information about the R-help mailing list