[R] keep dimension of a sub matrix
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Thu Nov 4 12:51:40 CET 2004
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
More information about the R-help
mailing list