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

classBreaks

Class breaks


Description

Finds class breaks in a distribution

Usage

classBreaks(x, n, type = c("equal", "quantile", "std", "geometric"))

Arguments

x

A vector to find breaks for

n

Number of breaks

type

Statistic used to find breaks c("equal", "quantile", "std", "geometric")

Value

A vector containing class break values the length is n+1 to allow for specification of ranges

Note

The robust std method uses sqrt(sum(x^2)/(n-1)) to center the data before deriving "pretty" breaks.

Author(s)

Jeffrey S. Evans <jeffrey_evans@tnc.org>

Examples

y <- rnbinom(100, 10, 0.5)
   classBreaks(y, 10)  
   classBreaks(y, 10, type="quantile")
 
opar <- par(no.readonly=TRUE)
   par(mfrow=c(2,2))
     d <- density(y)
     plot(d, type="n", main="Equal Area breaks")
       polygon(d, col="cyan")
       abline(v=classBreaks(y, 10)) 
     plot(d, type="n", main="Quantile breaks")
       polygon(d, col="cyan")
       abline(v=classBreaks(y, 10, type="quantile"))
     plot(d, type="n", main="Robust Standard Deviation breaks")
       polygon(d, col="cyan")
       abline(v=classBreaks(y, 10, type="std"))
     plot(d, type="n", main="Geometric interval breaks")
       polygon(d, col="cyan")
       abline(v=classBreaks(y, 10, type="geometric"))
 par(opar)
	
 ( y.breaks <- classBreaks(y, 10) )   	
 cut(y, y.breaks, include.lowest = TRUE, labels = 1:10)

spatialEco

Spatial Analysis and Modelling Utilities

v1.3-6
GPL-3
Authors
Jeffrey S. Evans [aut, cre], Melanie A. Murphy [ctb], Karthik Ram [ctb]
Initial release
2021-03-24

We don't support your browser anymore

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