#'
#'
#'
reduceDimByLevel <- function(data, limit){
# Show me the levels of all columns (To find the ones with the least).
l <- list()
for(i in 1:ncol(data)){
l[i] <- length(levels(data[,i]))
}
colLevels <- data.frame(colnames=colnames(data), level=unlist(l))
names <- as.character(colLevels[colLevels$level < limit,]$colnames)
rm(i, l, colLevels)
return(data[,names])
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.