Create a Factor Variable Using the Quantiles of a Continuous Variable

Description

Usage

Arguments

x

Continous variable.

q

Either a integer number of equally spaced quantile groups to
create, or a vector of quantiles used for creating groups. Defaults to
q=4 which is equivalent to q=seq(0, 1, by=0.25).
See quantile for details.

Details

This function uses quantile to obtain the specified
quantiles of x, then calls cut to create a factor
variable using the intervals specified by these quantiles.

It properly handles cases where more than one quantile obtains the
same value, as in the second example below. Note that in this case,
there will be fewer generated factor levels than the specified number
of quantile intervals.