binningfunctions | R Documentation |
Different functions that perform binning.
cut_at(breaks)
nearest(centers)
bin_by_ntile(nbins)
bin_by_eqcut(nbins)
bin_by_pam(nbins)
bin_by_classInt(style, nbins = NULL)
breaks |
A numeric vector of values that designate cut points between bins. |
centers |
A numeric vector of values that designate the center of each bin. |
nbins |
The number of bins to split the data into. |
style |
a binning style (see classIntervals for details). |
Each of these functions returns a function of a single numeric vector 'x' that assigns each value of 'x' to a bin.
x <- c(rnorm(10, 1, 1), rnorm(10, 3, 2), rnorm(20, 5, 3))
centers <- c(1, 3, 5)
nearest(centers)(x)
breaks <- c(2, 4)
cut_at(breaks)(x)
bin_by_eqcut(nbins=4)(x)
bin_by_ntile(nbins=4)(x)
bin_by_pam(nbins=4)(x)
bin_by_classInt("pretty", nbins=4)(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.