Count Entries in Bins

DESCRIPTION:

Counts the number of occurrences of integers.

USAGE:

tabulate(bin, nbins = max(bin), weights = NULL) 

REQUIRED ARGUMENTS:

bin
vector or bdVector of bin numbers, between 1 and nbins, inclusive. A category is appropriate for bin. Missing values are not accepted.

OPTIONAL ARGUMENTS:

nbins
maximum number of bins, at least as large as max(bin).
weights
if supplied, numeric vector the same length as bin. bdVector's are not supported.

VALUE:

vector or bdVector of length nbins. The ith element of the value counts the number of is that occurred in bin.

Or, if weights is supplied, the ith element of the value is the sum of weights for observations with bin == i.

DETAILS:

Takes a vector or bdVector, bin, and returns a vector or bdVector of length nbins. For each element, i, counts the number of is that occurred in bin. Or, if weights are supplied, returns the or the sum of weights corresponding to is in bin.

Missing values in bin are omitted. If weights is supplied, then missing values in either bin or weights cause the corresponding elements of both to be omitted.

SEE ALSO:

, , .

EXAMPLES:

tabulate(cut(lottery.payoff,10),10) 

x <- c(1:5, 5, 6, 6:8) 
tabulate(x) 
# Produces:
# [1] 1 1 1 1 2 2 1 1
tabulate(x, 15) 
# Produces:
# [1] 1 1 1 1 2 2 1 1 0 0 0 0 0 0 0 
tabulate(x, 8, weights = 1:10)
# [1]  1  2  3  4 11 15  9 10