| cut_equal | R Documentation |
This function uses cut to make categories based on approximately equal number of bins
cut_equal(x, n, type = 1, ntries = 1000)
x |
the vector that should be cut into equal bins |
n |
the number of bins that should be used |
type |
the type of algorithm to be used (see details) |
ntries |
number of samples/tries for type 2 |
Generating equal bins can be quite difficult. There are multiple ways of assessing if bins are equal. This function provides a method based on quantiles (type=1) or a method based on sampling proposed by M. Ruppert (type=2). In general type 1 is faster but less accurate, while type 2 is slower and more accurate (in case of a reasonable ntries)
a character vector with the categories/bins
Richard Hooijmaijers
table(cut_equal(1:20,5))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.