Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

nclass

Best number of classes for categorizing a continuous variable


Description

This function explores the best number of classes to categorize (discretize) a continuous variable.

Usage

nclass(x,th,...)

Arguments

x

a RasterLayer or a numeric vector

th

A threshold (default = 0.005) used to find the best number of classes

...

Additional arguments; currently probs implemented that specifies which extreme values (outliers) should be ignored; specified as a percentile probabilities, e.g., c(0.005,0.995), default is NULL

Details

The function uses an approach introduced in Naimi et al. (under review), to find the best number of classes (categories) when a continuous variable is discretizing. The threhold is corresponding to the acceptable level of information loose through discretizing procedure. For the details, see the reference.

Value

An object with the same class as the input x

Author(s)

Babak Naimi naimi.b@gmail.com

References

Naimi, B., Hamm, N. A., Groen, T. A., Skidmore, A. K., Toxopeus, A. G., & Alibakhshi, S. (2019). ELSA: Entropy-based local indicator of spatial association. Spatial statistics, 29, 66-88.

Examples

file <- system.file('external/dem_example.grd',package='elsa')
r <- raster(file)
plot(r,main='a continuous raster map')

nclass(r)

nclass(r, th=0.01)

nclass(r, th=0.1)

elsa

Entropy-Based Local Indicator of Spatial Association

v1.1-28
GPL (>= 3)
Authors
Babak Naimi [cre, aut] (<https://orcid.org/0000-0001-5431-2729>), Roger Bivand [ctb] (part of the dnn C code, from the spdep package), William Venables [ctb] (part of the dnn C code, taken from the spdep package), Brian Ripley [ctb] (part of the dnn C code, taken from the spdep package)
Initial release
2020-03-13

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.