Function to classify univariate vector to interval, a wrapper of classInt::classify_intervals()
.
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.k
must greater than3
.- 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
, ifTRUE
returns cols as a factor with intervals as labels rather than integers.- seed
(optional) Random seed number, default is
123456789
. Setting random seed is useful when the sample size is greater than3000
(the default value forlargeN
) and the data is discretized by sampling10%
(the default value forsamp_prop
).- ...
(optional) Other arguments passed to
classInt::classify_intervals()
, see?classInt::classify_intervals()
.
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] 5 3 2 2 3 2 3 2 2 2 5 2 2 3 2 2 5 2 2 1 2 2 2 3 3 2 3 2 2 3 3 2