Function to classify univariate vector to interval,a wrapper of classInt::classify_intervals().

st_unidisc(x, k, method = "quantile", factor = FALSE, ...)

Arguments

x

A continuous numerical variable.

k

(optional) Number of classes required, if missing, grDevices::nclass.Sturges() is used; see also the "dpih" and "headtails" styles for automatic choice of the number of classes.

method

Chosen classify style: one of "fixed", "sd", "equal", "pretty", "quantile", "kmeans", "hclust", "bclust", "fisher", "jenks", "dpih", "headtails", "maximum", or "box".Default is quantile.

factor

(optional) Default is FALSE, if TRUE returns cols as a factor with intervals as labels rather than integers.

...

(optional) Other arguments passed to classInt::classify_intervals(), see ?classInt::classify_intervals().

Value

A discrete vectors after being classified.

Author

Wenbo Lv lyu.geosocial@gmail.com

Examples

xvar = c(22361, 9573, 4836, 5309, 10384, 4359, 11016, 4414, 3327, 3408,
         17816, 6909, 6936, 7990, 3758, 3569, 21965, 3605, 2181, 1892,
         2459, 2934, 6399, 8578, 8537, 4840, 12132, 3734, 4372, 9073,
         7508, 5203)
st_unidisc(xvar,k = 6,method = 'sd')
#>  [1] 9 4 3 3 5 2 5 2 2 2 8 3 3 4 2 2 9 2 2 1 2 2 3 4 4 3 5 2 2 4 4 3