Learn R Programming

mapStats (version 1.14)

jiggleClass: Adjust class boundaries to protect from rounding errors

Description

When using classIntervals to compute classes, occasionally there are rounding errors so that when you go to plot data and use the class breaks for colors, for instance, the rounding error may cause a value to not be plotted with the right color, or to not be plotted at all. For this reason, we add a small value to each of the break points to accomodate a possible rounding error. When plotting, this correction will not be visible.

Usage

jiggleClass(x)

Arguments

x
an object of class classIntervals from the function classIntervals.

Value

  • an object of class classIntervals.

Examples

Run this code
library(classInt)
library(RColorBrewer)

y <- 100*rnorm(50)

#compute class intervals
class <- classIntervals(var=y, n=12, style="jenks")
class$brks

#there should be a slight difference now between class breaks
class <- jiggleClass(x=class)
class$brks

Run the code above in your browser using DataLab