Created
July 3, 2014 11:37
-
-
Save jonesor/9226171af14873ad332d to your computer and use it in GitHub Desktop.
Remove unused factor levels in a data frame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dropall <- function(x){ | |
isFac = NULL | |
for (i in 1:dim(x)[2]){isFac[i] = is.factor(x[ , i])} | |
for (i in 1:length(isFac)){ | |
x[, i] = x[, i][ , drop = TRUE] | |
} | |
return(x) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment