R/transform.R
xtile.RdSplit a numeric variable into a number of bins and return a vector of bin numbers
xtile(x, n = 5, rev = FALSE, type = 7)
| x | Numeric variable |
|---|---|
| n | number of bins to create |
| rev | Reverse the order of the bin numbers |
| type | An integer between 1 and 9 to select one of the quantile algorithms described in the help for the stats::quantile function |
See quantile for a description of the different algorithm types
xtile(1:10, 5)#> [1] 1 1 2 2 3 3 4 4 5 5xtile(1:10, 5, rev = TRUE)#> [1] 5 5 4 4 3 3 2 2 1 1#> [1] 1 1 1 1 1 1 4 4 5 5