# load packages
library(data.table)
# generate data
data <- data.table("a" = as.factor(round(rnorm(500, 10, 5))))
# view cumulative frequency without collpasing categories
CollapseCategory(data, "a", 0.2)
# 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