[R] removing invariant columns from a matrix

Peter Dalgaard p.dalgaard at biostat.ku.dk
Mon Aug 30 00:18:38 CEST 2004


"Moises Hassan" <mhassan at scitegic.com> writes:

> It works great, except that in the case where only one column is left,
> it returns a vector and the column name is lost. How can you avoid that
> behavior?

Just add drop=FALSE to the indexing i.e. A[,cond,drop=FALSE] 


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