cutEq: Cut into equal-sized groups.

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/latticistCompose.R

Description

Discretize using equally spaced quantiles for the breaks.

Usage

1
2
3
cutEq(x, n, type = 2, dig.lab = 4, ...)

reorderByFreq(x)

Arguments

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.

Details

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.

Value

cutEq returns an ordered factor. reorderByFreq returns a factor with the same values as its input, but with levels reordered.

Author(s)

Felix Andrews [email protected]

See Also

cut, cut2 in Hmisc package, reorder

Examples

1
2
3
4
5
6
7
8
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"

11010tianyi/latticist documentation built on May 28, 2017, 6:58 p.m.