tabulate {base}R Documentation

Tabulation for Vectors

Description

tabulate takes the integer-valued vector bin and counts the number of times each integer occurs in it.

Usage

tabulate(bin, nbins = max(1, bin))

Arguments

bin a numeric vector (of positive integers), or a factor.
nbins the number of bins to be used.

Details

tabulate is used as the basis of the table function.

If bin is a factor, its internal integer representation is tabulated.

If the elements of bin are numeric but not integers, they are truncated to the nearest integer.

Value

An integer vector (without names). There is a bin for each of the values 1, ..., nbins; values outside that range are (silently) ignored.

See Also

table, factor.

Examples

tabulate(c(2,3,5))
tabulate(c(2,3,3,5), nbins = 10)
tabulate(c(-2,0,2,3,3,5))  # -2 and 0 are ignored
tabulate(c(-2,0,2,3,3,5), nbins = 3)
tabulate(factor(letters[1:10]))

[Package base version 2.2.1 Index]