| cutEq {playwith} | R Documentation |
Discretize using equally spaced quantiles for the breaks.
cutEq(x, n, type = 2, dig.lab = 4, ...) reorderByFreq(x)
x |
for cutEq, a numeric vector.
for reorderByFreq, a factor variable. |
n |
number of levels (groups) to cut into. |
type |
type of quantile, see quantile. |
dig.lab |
digits to use in formatting labels. |
... |
ignored. |
cutEq is similar to cut but divides into roughly
equally-sized groups, rather than dividing into bins of equal width.
reorderByFreq orders levels of a factor by their frequency.
It is basically reorder(x, x, length), but reversed.
cutEq returns an ordered factor.
reorderByFreq returns a factor with the same values as its
input, but with levels reordered.
Felix Andrews felix@nfrac.org
cut, cut2 in Hmisc package, reorder
summary(cut(rnorm(100), 4, dig=2))
summary(cutEq(rnorm(100), 4, dig=2))
foo <- factor(c("c","b","b","a"))
levels(foo)
# "a" "b" "c"
levels(reorderByFreq(foo))
# "b" "a" "c"