quantcut {gregmisc} | R Documentation |
Create a factor variable using the quantiles of a continous variable.
quantcut(x, q=c(0, 1/4, 2/4, 3/4, 4/4), na.rm=TRUE, include.lowest=TRUE, ...)
x |
Continous variable. |
q |
Vector of quantiles used for creating groups. Defaults to
c(0, 1/4, 2/4, 3/4, 4/4) . See quantile for details. |
na.rm |
Boolean indicating whether missing values should be removed when computing quantiles. Defaults to TRUE. |
include.lowest |
Boolean indicating whether values exactly
equal to the lowest specified quantile be included in the lowest
group. See cut for details. |
... |
Optional arguments passed to cut . |
This function is simply a uses quantile
to obtaine the
quantiles of x
, then calls cut
to create a factor
variable using the quantiles for cut points.
Factor variable with one level for each quantile interval given by q
.
Gregory R. Warnes Gregory_R_Warnes@groton.pfizer.com
x <- rnorm(1000) quants <- quantcut( x ) table(quants)