# NOT RUN {
# load packages
library(data.table)
# generate data
data <- data.table("a" = as.factor(round(rnorm(500, 10, 5))), "b" = rexp(500, 1:500))
# view cumulative frequency without collpasing categories
CollapseCategory(data, "a", 0.2)
# view cumulative frequency based on another measure
CollapseCategory(data, "a", 0.2, measure = "b")
# collapse bottom 20% categories based on cumulative frequency
CollapseCategory(data, "a", 0.2, update = TRUE)
BarDiscrete(data)
# }
Run the code above in your browser using DataLab