Remove columns from dataframe based on their statistics
On Thu, May 31, 2012 at 8:52 AM, J Toll <jctoll at gmail.com> wrote:
for (i in seq(ncol(df), 1))
?if (length(unique(df[, i])) == 1) {
?df[, i] <- NULL
}
Here's a similar method employing a more functional approach: df[, apply(df, 2, function(x) length(unique(x)) > 1)] James