x
into intervals, so that each interval contains a minimum number of values, and codes the values in x
according to which interval they fall into.
cutWithMinN(x, intervals=2, min.n=1)
length(x)/intervals
.x
indicating which interval each value belongs to.intervals+1
giving the left and right limits of each interval.cut
,
which by default cuts a vector into equal length intervals,
and quantile
, which is suited to finding equally populated intervals.
It finds a partition of the x
values that is as close as possible to equal length intervals while keeping at least min.n
values in each interval.Tied values of x
are broken by random jittering, so the partition may vary slightly from run to run if there are many tied values.
cut
, quantile
.
x <- c(1,2,3,4,5,6,7,100)
cutWithMinN(x,intervals=3,min.n=1)
Run the code above in your browser using DataLab