search for: col_means

Displaying 1 result from an estimated 1 matches for "col_means".

Did you mean: col1_mean
2011 Nov 09
2
algorithm that iteratively drops columns of a data-frame
...columns with the smallest means ? It is a pretty generic example) here is the sample code: x1 <- rnorm(200, 5, 2) x2 <- rnorm(200, 6, 2) x3 <- rnorm(200, 1, 2) x4 <- rnorm(200, 12, 2) x5 <- rnorm(200, 8, 2) x6 <- rnorm(200, 9, 2) data <- data.frame(x1, x2, x3, x4, x5,x6) col_means <- colMeans(data) drop <- match(min(col_means), col_means) for(i in 1:4) { col_means <- colMeans(data[,-drop]) drop <- c(drop, match(min(col_means), col_means)) }