Learn R Programming

berryFunctions (version 1.5.2)

classify: classification into groups

Description

classify continuous values into categories with different methods: linearly spaced equal intervals, intervals based on quantiles (equally filled bins) or distance from the mean in normal distributions, or user specified class borders, e.g. for legal or critical limits.

Usage

classify(x, method="equalinterval", breaks, Range=range(x, finite=TRUE), sdlab=1)

Arguments

x
Vector with numeric values
method
Character string (partial matching is performed). Classification method or type of binning to compute the class breakpoints. See section Details. DEFAULT: "equalinterval")
breaks
Specification for method, see Details. DEFAULT: different defaults for each method
Range
Ends of color bar for method=equalinterval. DEFAULT: range(x, finite=TRUE)
sdlab
Type of label and breakpoints if method=standarddeviation. 1 means -0.5 sd, 0.5 sd, 2 means -1 sd, mean, 1 sd, 3 means actual numbers for type 1, 4 means numbers for type 2.

Value

  • list with class numbers (index) and other elements for colPoints

Details

This is the workhorse for colPoints. Binning methods are explained very nicely in the link in the section References. nbins indicates the number of classes (and thus, colors). llll{ method | explanation | meaning of breaks | default equalinterval | nbins equally spaced classes | nbins | 100 quantile | classes have equal number of values | the quantiles (or number of them) | 0:4/4 standarddeviation | normal distributions | the number of sd in one direction from the mean | 3 usergiven | custom breakpoints | personal breakpoint values (including ends of Range) | none } The default is set to equalinterval which makes sense for my original intent of plotting lake depth (bathymetry measured at irregularly distributed points) on a linear color scale.

References

See this page on the effect of classification (binning) methods: http://uxblog.idvsolutions.com/2011/10/telling-truth.html

See Also

colPoints

Examples

Run this code
classify( c(1:10, 20), breaks=12)
classify( c(1:10, 20), "q", breaks=0:10/10)
classify( c(1:10, 20), "s", sdlab=2 )

Run the code above in your browser using DataLab