binningfunctions: Different functions that perform binning.

binningfunctionsR Documentation

Different functions that perform binning.

Description

Different functions that perform binning.

Usage

cut_at(breaks)

nearest(centers)

bin_by_ntile(nbins)

bin_by_eqcut(nbins)

bin_by_pam(nbins)

bin_by_classInt(style, nbins = NULL)

Arguments

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).

Value

Each of these functions returns a function of a single numeric vector 'x' that assigns each value of 'x' to a bin.

Examples


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)


tidyvpc documentation built on May 29, 2024, 8:29 a.m.