[R] Excluding all teh columns from a data frame if the standard deviation of that column is zero(0).

siddu479 onlyfordigitalstuff at gmail.com
Tue Oct 16 10:08:17 CEST 2012


Hi All,

  I have a data frame where nearly 10K columns of data, where most of them
have standard deviation( of all rows) as zero.
I want to exclude all the columns from the data frame and proceed to further
processing.

I tried like blow.  
*data <- read.csv("data.CSV", header=T)

for(i in 2:ncol(data))
 if(sd(data[,i])==0){
 df[,i] <-NULL
}
*
where I have the data columns from 2:ncol, but getting the error "Error in
df[, i] <- NULL : object of type 'closure' is not subsettable"

Can any one suggest the right method to accomplish this.






-----
Sidda
Business Analyst Lead
Applied Materials Inc.

--
View this message in context: http://r.789695.n4.nabble.com/Excluding-all-teh-columns-from-a-data-frame-if-the-standard-deviation-of-that-column-is-zero-0-tp4646310.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list