Description Usage Arguments Examples
View source: R/grouping_and_binning.R
Group categories by (cumulative) frequencies
1 2 3 |
other_cat_name |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | library(mdmisc)
set.seed(2016)
dt <- data.table::data.table('cat' = sample(letters[1:10], 20, replace = TRUE), 'cont' = rnorm(20))
## View cumulative frequencies
group_by_threshold(dt, 'cat')
group_by_threshold(dt, 'cat', threshold = 0.10)
group_by_threshold(dt, 'cat', cum_threshold = 0.90)
group_by_threshold(dt, 'cat', no_of_categories = 3)
## Group categories below 10\% of frequency
dt_mod <- group_by_threshold(dt, 'cat', threshold = 0.10, return_data = TRUE)
group_by_threshold(dt_mod, 'cat')
## Group bottom 10\% categories based on cumulative frequency
dt_mod <- group_by_threshold(dt, 'cat', cum_threshold = 0.90, return_data = TRUE)
group_by_threshold(dt_mod, 'cat')
## Leave 3 categories based on frequency
dt_mod <- group_by_threshold(dt, 'cat', no_of_categories = 3, return_data = TRUE)
group_by_threshold(dt_mod, 'cat')
## Group and modify in place
group_by_threshold(dt, 'cat', threshold = 0.1, return_data = TRUE, modify = TRUE)
group_by_threshold(dt, 'cat')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.