[R] removing invariant columns from a matrix

Liaw, Andy andy_liaw at merck.com
Sun Aug 29 01:39:43 CEST 2004


Something like:

keep <- apply(myData, 2, function(x) diff(range(x)) > 0)
newData <- myData[, keep]

Andy

> From: Moises Hassan
> 
> I'm looking for an efficient way of removing zero-variance 
> columns from
> a large matrix.
> 
> Any suggestions?
> 
> Thanks,
> 
>    - Moises
>




More information about the R-help mailing list