Description Usage Arguments Details Value See Also Examples
bins
- Cuts points in vector x into evenly distributed groups (bins).
bins
takes 3 separate approaches to generating the cuts, picks the one
resulting in the least mean square deviation from the ideal cut -
length(x) / target.bins
points in each bin - and then merges small bins
unless excat.groups is TRUE
1 |
x |
Vector of numbers |
target.bins |
Number of groups desired; this is also the max number of groups. |
max.breaks |
Used for initial cut. If |
exact.groups |
if TRUE, the result will have exactly the number of target.bins; if FALSE, the result may contain fewer than target.bins bins |
verbose |
Indicates verbose output. |
errthresh |
If the error is below the provided value, stops after the first rough estimate of the bins. |
minpts |
Minimum number of points in a bin.
In |
The gains are computed using incremental analytical expresions derived for moving a value from one bin to the next, splitting a bin into two or merging two bins.
A list containing the following items (not all of them may be present):
gain - Error gain obtained as the result of the function call.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## Not run:
# Seriously skewed x:
x <- floor(exp(rnorm(200000 * 1.3)))
cuts <- bins(x, target.bins = 10, minpts = 2000)
cuts$breaks <- bins.getvals(cuts)
cuts$binct
# [0, 0] [1, 1] [2, 2] [3, 3] [4, 4] [5, 5] [6, 7] [8, 10]
# 129868 66611 28039 13757 7595 4550 4623 2791
# [11, 199]
# 2166
# Centered x:
x <- rep(c(1:10,20,31:40), c(rep(1, 10), 100, rep(1,10)))
cuts <- bins(x, target.bins = 3, minpts = 10)
cuts$binct
# [1, 10] [20, 20] [31, 40]
# 10 100 10
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.