[R] removing invariant columns from a matrix

Peter Dalgaard p.dalgaard at biostat.ku.dk
Sun Aug 29 01:37:15 CEST 2004


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

> I'm looking for an efficient way of removing zero-variance columns from
> a large matrix.
> 
> Any suggestions?

A[,apply(A,2,var)>0]

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