Equal frequency discretization in R

前端 未结 8 1560
南方客
南方客 2020-12-17 02:56

I\'m having trouble finding a function in R that performs equal-frequency discretization. I stumbled on the \'infotheo\' package, but after some testing I found that the al

8条回答
  •  Happy的楠姐
    2020-12-17 03:54

    Here's another solution using mltools.

    set.seed(1)
    x <- round(rnorm(20), 2)
    x.binned <- mltools::bin_data(x, bins = 5, binType = "quantile")
    table(x.binned)
    
    x.binned
    [-2.21, -0.622)   [-0.622, 0.1)    [0.1, 0.526)  [0.526, 0.844)    [0.844, 1.6] 
                  4               4               4               4               4 
    

提交回复
热议问题