Learn R Programming

bda (version 10.1.9)

binning: Data Binning

Description

To bin a univariate data set in to a consecutive bins.

Usage

binning(x, counts, nclass, breaks, bw)

Arguments

x

A vector of raw data. 'NA' values will be automatically removed.

counts

Frequencies or counts of observations in different classes (bins)

nclass

Number of classes

breaks

The break points for data binning.

bw

Bin (class) width.

Details

Data binning can be done in the following cases: (1) both x and breaks are specified; (2) both counts and breaks are specified; (3) both x and bw are specified. If (3a) breaks is of length 1, it gives the lower limit of the first bin/class, and a sequence of equal-width bins will be defined. If (3b) breaks is missing, a random starting point will be chosen.

x and counts cannot be both given.

nclass will not be used if x is missing.

Examples

Run this code
# NOT RUN {
  y <- c(10, 21, 56,79,114,122,110,85,85,61,47,49,47,44,31,20,11,4,4)
  x <- 14.5 + c(0:length(y))
  out1 <- binning(counts=y, breaks=x)
  plot(out1)

# }

Run the code above in your browser using DataLab