bda (version 14.3.19)

binning: Data Binning

Description

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

Usage

binning(x, counts, breaks,lower.limit, upper.limit)

Arguments

x

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

counts

Frequencies or counts of observations in different classes (bins)

breaks

The break points for data binning.

lower.limit, upper.limit

The lower and upper limits of the bins.

Value

ll

lower limits

ul

upper limits

freq

frequencies

xhist

histogram

xZipf

Zipf plot

Details

To create a 'bdata' object. If 'x' is given, a histogram will be created. Otherwise, create a histogram-type data using 'counts' and 'breaks' (or class limits with 'lower.limit' and/or 'upper.limit').

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)

z = rnorm(100, 34.5, 1.6)
out1 <- binning(z)
plot(out1)

data(FSD)

x <- as.numeric(FirmAge[38,]);
age <- c(0,1:6,11,16,21,26,38);
y <- binning(counts=x, lower.limit=age)
plot(y)
plot(y, type="Zipf")

x <- as.numeric(FirmSize[38,]);
names(FirmSize)
ll <- c(1,5,10,20,50,100,250,500,1000,2500,5000,10000);
ul <- c(4,9,19,49,99,249,499,999,2499,4999,9999,Inf)
y <- binning(counts=x, lower.limit=ll,upper.limit=ul)
plot(y)
plot(y, type="Zipf")
# }

Run the code above in your browser using DataLab