View source: R/getJenksBreaks.R
| getJenksBreaks | R Documentation | 
Given a vector of numeric values and the number of desired breaks, calculate the optimum breakpoints using Jenks natural breaks optimization.
getJenksBreaks(var, k, subset = NULL)
var | 
 Numeric vector.  | 
k | 
 Number of breaks.  | 
subset | 
 Number of regularly spaced samples to subset from
  | 
getJenksBreaks is called by
assignColorBreaks.
The values in var are binned into k+1 categories,
according to the Jenks natural breaks classification method. This
method is borrowed from the field of cartography, and seeks to
minimize the variance within categories, while maximizing the variance
between categories. If subset = NULL, all values of var
are used for the optimization, however this can be a slow process with
very large datasets. If subset is set to some number, then 
subset regularly spaced values of var will be sampled.
This is slightly less accurate than when using the entirety of
var but is unlikely to make much of a difference. If 
subset is defined but length(var) < subset, then
subset has no effect.  
The Jenks natural breaks method was ported to C from code found in the classInt R package.
A numeric vector of intervals.
Pascal Title
See assignColorBreaks and
plot.bammdata.
# load whales dataset
data(whales, events.whales)
ed <- getEventData(whales, events.whales, burnin=0.25, nsamples=500)
# for demonstration purposes, extract the vector of speciation rates
ed <- dtRates(ed, tau=0.01)
vec <- ed$dtrates$rates[[1]]
# Return breaks for the binning of speciation rates into 65 groups
# yielding 64 breaks
getJenksBreaks(vec, 64)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.