[R] Remove columns from dataframe based on their statistics

Johannes Radinger JRadinger at gmx.at
Thu May 31 15:27:21 CEST 2012


Hi,

I have a dataframe and want to remove columns from it
that are populated with a similar value (for the total
column) (the variation of that column is 0). Is there an
easier way than to calculate the statistics and then
remove them by hand?

A <- runif(100)
B <- rep(1,100)
C <- rep(2.42,100)
D <- runif(100)
df <- data.frame(A,B,C,D) # if want to conditionally remove column B and C as they show no variations

/Johannes
-- 

Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a



More information about the R-help mailing list