binning: Data Binning

Description Usage Arguments Details Value Examples

View source: R/binning.R

Description

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

Usage

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

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

Value

ll

lower limits

ul

upper limits

freq

frequencies

xhist

histogram

xZipf

Zipf plot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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")

Example output

bda v15 (Bin Wang, 2020)
 [1] "1-4"         "5-9"         "10-19"       "20-49"       "50-99"      
 [6] "100-249"     "250-499"     "500-999"     "1,000-2,499" "2,500-4,999"
[11] "5,000-9,999" "10,000+"    

bda documentation built on Aug. 19, 2021, 9:06 a.m.

Related to binning in bda...