bin_series: State Binning

Description Usage Arguments Value Examples

View source: R/binning.R

Description

Bin a continuously-valued times series. The binning can be performed in any one of three ways. The first is binning the time series into b uniform bins (with b an integer). The second type of binning produces bins of a specific size step. The third type of binning breaks the real number line into segments with specified boundaries or thresholds, and the time series is binned according to this partitioning. The bounds are expected to be provided in ascending order.

Usage

1
bin_series(series, b = NA, step = NA, bounds = NA)

Arguments

series

Vector of the continuously-valued time series to bin.

b

Numeric giving the desired number of uniform bins.

step

Numeric giving the desired size of each uniform bin.

bounds

Vector of the finite bounds of each bin.

Value

List giving the binned sequence, the number of bins and either the bin sizes or bin bounds.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# First method: bin into uniform bins
xs <- runif(20, 0, 5)
bin_series(xs, b = 5)

# Second method: bins of specific size <step>
bin_series(xs, step = 1)

# Third method: bins of specific size <step>
bounds <- c(2.0, 5.0)
bin_series(xs, bounds = bounds)

rinform documentation built on April 1, 2018, 12:12 p.m.