On Thu, May 31, 2012 at 8:52 AM, J Toll <jct...@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 ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.