bin: Calculate Bin Sizes and Limits for a Vector

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Given a numeric vector, calculate bin limits, place each value in a bin, and return the number of values in each bin.

Usage

1
2
3
4
5
6
7
8
bin(
	x,
	population=x,
	breaks=quantile(population,probs=probs,...),
	probs=c(0,0.25,0.5,0.75,1),
	include.lowest=TRUE,
	...
)

Arguments

x

a vector of numeric values, to be placed in bins

population

a vector of numeric values serving as the reference population for constructing bins

breaks

bin limits (boundaries) to pass to cut

include.lowest

limit qualifier to pass to cut

probs

default probabilities for calculating breaks

...

other arguments to pass to quantile and cut

Details

By default, the population used to calculate bin limits is the same as the group of values being binned. By default, inner bin limits are the quartiles of the population.

Value

A table with bin limits encoded as column names.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
bin(1:100)
bin(1:50,population=1:100)
plot(
    bin(
    	rnorm(1000), 
	breaks=seq(
		from=-3,
		to=3,
		by=0.5
	)
    )
)

metrumrg documentation built on May 2, 2019, 5:55 p.m.