Equal frequency discretization in R

前端 未结 8 1572
南方客
南方客 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条回答
  •  情书的邮戳
    2020-12-17 03:49

    Here is a one liner solution inspired by @Joris' answer:

    x <- rpois(50,5)
    binSize <- 5
    desiredFrequency = floor(length(x)/binSize)
    split(sort(x), rep(1:binSize, rep(desiredFrequency, binSize)))
    

提交回复
热议问题