Togaware DATA MINING
Desktop Survival Guide
by Graham Williams
Google

Remove Variables with no Variance

We also only want columns where there is some variance in the values, so also remove those columns with a minimum value equal to the maximum. Again, use is made of lapply to apply a function (in this case max and min) to the data.



> rmcols <- as.numeric(lapply(dat, min, na.rm=T)) ==
            as.numeric(lapply(dat, max, na.rm=T))
> rmcols <- rev(seq(1,ncol(dat))[rmcols])
> for (i in rmcols) dat[[i]] <- NULL
> ncol(dat)
[1] 59



Copyright © Togaware Pty Ltd
Support further development through the purchase of the PDF version of the book.
The PDF version is a formatted comprehensive draft book (with over 800 pages).
Brought to you by Togaware. This page generated: Sunday, 22 August 2010